UPnP交互网络包示例
转载文章,原文链接
1 概况
1.1 基础协议
- SOAP(Simple Object Access Protocol)
- SSDP(Simple Service Discovery Protocol)
- GENA(Generic Event Notification Architecture)
- SCPD/DDD(Service Control Protocol Description)
1.2 UPnP Device Architecture (UDA)
- Addressing : IP assignment on any network (AutoIP)
- Discovery : Of services/devices (SSDP)
- Description : Syntax for devices/services (SCPD/DDD)
- Control : Of device services (SOAP)
- Eventing : Updates of variables (GENA)
- Presentation : Access to device HTML page
1.3 Device Control Protocols (DCPs)
- APIs for various device functionality
- Described using SCPD syntax and UDA protocols
1.4 UPnP Architecture Diagram
Standard Services Device Control Protocols
Common Architecture 3.Control; 4.Eventing; 5.Presentation
2.Description
1.Discovery
0.Addressing
Base HTTP, XML, TCP, UDP, IP
2 协议
2.1 术语
- NT (Notification Type)
- NTS (Notification Sub Type)
- USN (Unique Service Name)
- UDN (Unique Device Name)
- SID (Subscription IDentifier)
2.2 发现(Discovery)
2.2.1 Advertising
多播内容:
- 1 time / service type with NT == service type
- 1 time / device type with NT == device type
- 1 time / device with NT == device UUID
- 1 time with NT == upnp:rootdevice
如:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age = seconds until advertisement expires
LOCATION: URL for UPnP description for root device
NT: search target
NTS: ssdp:alive
USN: advertisement UUID
2.2.2 Searching
多播内容:
- ST one of:
- Service type, Device type, Device UUID
- upnp:rootdevice
- ssdp:all
如:
M-SEARCH * HTTP/1.1
MX: 3
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
ST: ssdp:all
2.2.3 Responding
单播内容:
- 1 time for each NT that matches
- Simple service name matching
如:
HTTP/1.1 200 OK
Location: http://172.16.5.92:1074/
Cache-Control: max-age=1800
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
EXT:
USN: uuid:2b82a0e2-27b0-b245-80bd-8922a9494b47::upnp:rootdevice
ST: upnp:rootdevice
Date: Wed, 17 Feb 2016 09:41:57 GMT
2.3 描述
2.3.1 设备描述
<root xmlns:dlna="urn:schemas-dlna-org:device-1-0"
configid="2369201"
xmlns="urn:schemas-upnp-org:device-1-0">
<specversion>
<major>1</major>
<minor>1</minor>
</specversion>
<device>
<!-- 物理描述: -->
<friendlyname>miketest platinum upnp media server</friendlyname>
<manufacturer>plutinosoft</manufacturer>
<manufacturerurl>http://www.plutinosoft.com/</manufacturerurl>
<modeldescription>platinum file media server</modeldescription>
<modelname>platinum file media server</modelname>
<modelnumber>1.0</modelnumber>
<modelurl>http://www.plutinosoft.com/</modelurl>
<serialnumber>xxx</serialnumber>
<udn>uuid:9081d7c5-7b76-a146-613c-b5188bc1bcb4</udn>
<upc>universal product product code</upc>
<!-- 逻辑描述: -->
<devicetype>urn:schemas-upnp-org:device:mediaserver:1</devicetype>
<dlna:x_dlnadoc xmlns:dlna="urn:schemas-dlna-org:device-1-0">dms-1.50</dlna:x_dlnadoc>
<servicelist>
<service>
<servicetype>urn:schemas-upnp-org:service:contentdirectory:1</servicetype>
<serviceid>urn:upnp-org:serviceid:contentdirectory</serviceid>
<scpdurl>/contentdirectory/9081d7c5-7b76-a146-613c-b5188bc1bcb4/scpd.xml</scpdurl>
<controlurl>/contentdirectory/9081d7c5-7b76-a146-613c-b5188bc1bcb4/control.xml
</controlurl>
<eventsuburl>/contentdirectory/9081d7c5-7b76-a146-613c-b5188bc1bcb4/event.xml
</eventsuburl>
</service>
<service>
<servicetype>urn:schemas-upnp-org:service:connectionmanager:1</servicetype>
<serviceid>urn:upnp-org:serviceid:connectionmanager</serviceid>
<scpdurl>/connectionmanager/9081d7c5-7b76-a146-613c-b5188bc1bcb4/scpd.xml</scpdurl>
<controlurl>/connectionmanager/9081d7c5-7b76-a146-613c-b5188bc1bcb4/control.xml
</controlurl>
<eventsuburl>/connectionmanager/9081d7c5-7b76-a146-613c-b5188bc1bcb4/event.xml
</eventsuburl>
</service>
</servicelist>
<!-- 其他描述: -->
<iconlist>
<icon>
<mimetype>image/png</mimetype>
<width>72</width>
<height>72</height>
<depth>32</depth>
<url>/dev/9081d7c5-7b76-a146-613c-b5188bc1bcb4/icon.png</url>
</icon>
</iconlist>
<presentationurl>url for presentation</presentationurl>
</device>
</root>
上面是MediaServer, 所以serviceList中包括ContentDirectory, ConnectionManager两种服务. 如果是MediaRenderer, 则包括: AVTransport, ConnectionManager, RenderingControl几种服务.
2.3.2 服务描述
<!--?xml version="1.0" encoding="utf-8"?-->
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specversion>
<major>1</major>
<minor>0</minor>
</specversion>
<!-- 动作(action)描述: -->
<actionlist>
<action>
<name>browse</name>
<argumentlist>
<argument>
<name>objectid</name>
<direction>in</direction>
<relatedstatevariable>a_arg_type_objectid</relatedstatevariable>
</argument>
...
<argument>
<name>result</name>
<direction>out</direction>
<relatedstatevariable>a_arg_type_result</relatedstatevariable>
</argument>
...
</argumentlist>
</action>
<action>
<name>getsortcapabilities</name>
<argumentlist>
<argument>
<name>sortcaps</name>
<direction>out</direction>
<relatedstatevariable>sortcapabilities</relatedstatevariable>
</argument>
</argumentlist>
</action>
...
</actionlist>
<!-- 状态变量描述 -->
<servicestatetable>
<statevariable sendevents="no">
<name>a_arg_type_browseflag</name>
<datatype>string</datatype>
<allowedvaluelist>
<allowedvalue>browsemetadata</allowedvalue>
<allowedvalue>browsedirectchildren</allowedvalue>
</allowedvaluelist>
</statevariable>
<statevariable sendevents="yes">
<name>systemupdateid</name>
<datatype>ui4</datatype>
</statevariable>
...
</servicestatetable>
</scpd>
2.4 控制
2.4.1 通用协议格式
命令:
POST path of control URL HTTP/1.1
HOST: host of control URL:port of control URL
CONTENT-LENGTH: bytes in body
CONTENT-TYPE: text/xml; charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:serviceType:v#actionName"
<!--?xml version="1.0"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:actionname xmlns:u="urn:schemas-upnp-org:service:serviceType:v">
<argumentname>in arg value</argumentname>
other in args and their values go here, if any
</u:actionname>
</s:body>
</s:envelope>
响应:
HTTP/1.1 200 OK
CONTENT-LENGTH: bytes in body
CONTENT-TYPE: text/xml; charset="utf-8"
DATE: when response was generated
EXT:
SERVER: OS/version UPnP/1.0 product/version
<!--?xml version="1.0"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:actionnameresponse xmlns:u="urn:schemas-upnp-org:service:serviceType:v">
<argumentname>out arg value</argumentname>
other out args and their values go here, if any
</u:actionnameresponse>
</s:body>
</s:envelope>
2.4.2 Browse
2.4.2.1 浏览目录
Action:
POST /ContentDirectory/f1062579-d833-971e-8db8-76b28da5dc2d/control.xml HTTP/1.1
SOAPAction: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"
User-Agent: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.5.13
Host: 172.16.5.92:1873
Content-Length: 571
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<objectid>0</objectid>
<browseflag>BrowseDirectChildren</browseflag>
<filter>dc:date,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,\
upnp:album,upnp:artist,upnp:author,searchable,childCount
</filter>
<startingindex>0</startingindex>
<requestedcount>30</requestedcount>
<sortcriteria></sortcriteria>
</u:browse>
</s:body>
</s:envelope>
Response:
HTTP/1.1 200 OK
Ext:
Date: Thu, 01 Jan 1970 16:56:28 GMT
Content-Length: 1083
Content-Type: text/xml; charset="utf-8"
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:browseresponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<result>
<didl-lite xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
<container
id="0/usb"
parentid="0"
restricted="1">
<dc:title>usb</dc:title>
<upnp:genre>Unknown</upnp:genre>
<upnp:class>object.container.storageFolder</upnp:class>
</container>
<container
id="0/LiveProgram"
parentid="0"
restricted="1">
<dc:title>LiveProgram</dc:title>
<upnp:genre>Unknown</upnp:genre>
<upnp:class>object.container.storageFolder</upnp:class>
</container>
</didl-lite>
</result>
<numberreturned>2</numberreturned>
<totalmatches>2</totalmatches>
<updateid>1</updateid>
</u:browseresponse>
</s:body>
</s:envelope>
2.4.2.2 浏览文件
Action:
POST /ContentDirectory/260ae85c-6cc5-4734-86ff-9f5753971493/control.xml HTTP/1.1
SOAPAction: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"
User-Agent: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.5.13
Host: 172.16.5.92:1135
Content-Length: 585
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<objectid>0/usb/media/mp4</objectid>
<browseflag>BrowseDirectChildren</browseflag>
<filter>dc:date,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,\
upnp:album,upnp:artist,upnp:author,searchable,childCount
</filter>
<startingindex>0</startingindex>
<requestedcount>30</requestedcount>
<sortcriteria></sortcriteria>
</u:browse>
</s:body>
</s:envelope>
Response:
HTTP/1.1 200 OK
Ext:
Date: Thu, 01 Jan 1970 19:39:07 GMT
Content-Length: 1567
Content-Type: text/xml; charset="utf-8"
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:browseresponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<result>
<didl-lite xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
<item
id="0/usb/media/mp4/alan.mp4"
parentid="0/usb/media/mp4"
restricted="1">
<dc:title>alan</dc:title>
<upnp:genre>Unknown</upnp:genre>
<res
protocolinfo="http-get:*:video/mp4:DLNA.ORG_PN=MPEG4_P2_SP_AAC; \
DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000"
size="37748317">
http://172.16.5.92:1135/usb/%25/media/mp4/alan.mp4
</res>
<upnp:class>object.item.videoItem</upnp:class>
</item>
<item
id="0/usb/media/mp4/avenger.mp4"
parentid="0/usb/media/mp4"
restricted="1">
<dc:title>avenger</dc:title>
<upnp:genre>Unknown</upnp:genre>
<res
protocolinfo="http-get:*:video/mp4:DLNA.ORG_PN=MPEG4_P2_SP_AAC; \
DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000"
size="133090990">
http://172.16.5.92:1135/usb/%25/media/mp4/avenger.mp4
</res>
<upnp:class>object.item.videoItem</upnp:class>
</item>
</didl-lite>
</result>
<numberreturned>2</numberreturned>
<totalmatches>2</totalmatches>
<updateid>1</updateid>
</u:browseresponse>
</s:body>
</s:envelope>
2.4.3 SetAVTransportURI
Action:
POST /AVTransport/a9e91358-f1d3-8081-6700-657b903a4cdf/control.xml HTTP/1.1
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
User-Agent: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.5.13
Host: 172.16.5.92:1146
Content-Length: 1318
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:setavtransporturi xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<instanceid>0</instanceid>
<currenturi>
http://172.16.5.90:1191/%25/F378CB0AC0D9CF6C47F2E8675FF24DEF/buildings_alan.mp4
</currenturi>
<currenturimetadata>
<didl-lite xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
<item
id="/media/f/avstream/mp4/buildings_alan.mp4"
parentid="/media/f/avstream/mp4/"
restricted="1">
<dc:title>buildings_alan</dc:title>
<dc:creator>Unknown</dc:creator>
<dc:date>2015-05-20T00:00:00Z</dc:date>
<upnp:genre>Unknown</upnp:genre>
<res
protocolinfo="http-get:*:video/mp4:DLNA.ORG_PN=MPEG4_P2_SP_AAC; \
DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000"
size="136059975">
http://172.16.5.90:1191/%25/F378CB0AC0D9CF6C47F2E8675FF24DEF/buildings_alan.mp4
</res>
<upnp:class>object.item.videoItem</upnp:class>
</item>
</didl-lite>
</currenturimetadata>
</u:setavtransporturi>
</s:body>
</s:envelope>
Response:
HTTP/1.1 200 OK
Ext:
Date: Thu, 01 Jan 1970 21:03:21 GMT
Content-Length: 277
Content-Type: text/xml; charset="utf-8"
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:setavtransporturiresponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"></u:setavtransporturiresponse>
</s:body>
</s:envelope>
2.4.4 Play
如下: i3/i21: ... 等行表示包发送的方向. 本例中172.16.5.90为CP, 172.16.5.92为Renderer,.
-
CP(.90)向Renderer(.92)发送Play命令:
i3 : 172.16.5.90:52172 > 172.16.5.92:1146, len:594
POST /AVTransport/a9e91358-f1d3-8081-6700-657b903a4cdf/control.xml HTTP/1.1
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#Play"
User-Agent: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.5.13
Host: 172.16.5.92:1146
Content-Length: 306
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<instanceid>0</instanceid>
<speed>1</speed>
</u:play>
</s:body>
</s:envelope>
-
Renderer(.92)告知TRANSITIONING:
i21 : 172.16.5.92:40036 > 172.16.5.90:1334, len:603
NOTIFY /a9e91358-f1d3-8081-6700-657b903a4cdf/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:db690087-714d-0ba5-fec8-7d19a4dbf60d
SEQ: 2
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1334
Content-Length: 324
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<transportstate val="TRANSITIONING"></transportstate>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
i23 : 172.16.5.90:1334 > 172.16.5.92:40036, len:111
HTTP/1.1 200 OK
Date: Fri, 08 Apr 2016 03:55:19 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
-
Renderer(.92)获取流内容:
i487 : 172.16.5.92:43241 > 172.16.5.90:1191, len:191
GET /%25/F378CB0AC0D9CF6C47F2E8675FF24DEF/buildings_alan.mp4 HTTP/1.1
User-Agent: Lavf/57.25.100
Accept: */*
Range: bytes=0-
Connection: close
Host: 172.16.5.90:1191
Icy-MetaData: 1
GET /%25/F378CB0AC0D9CF6C47F2E8675FF24DEF/buildings_alan.mp4 HTTP/1.1
...
-
Renderer(.92)回复Play命令OK:
i1550 : 172.16.5.92:1146 > 172.16.5.90:52172, len:442
HTTP/1.1 200 OK
Ext:
Date: Thu, 01 Jan 1970 21:03:38 GMT
Content-Length: 264
Content-Type: text/xml; charset="utf-8"
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
<!--?xml version="1.0" encoding="UTF-8"?-->
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:body>
<u:playresponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"></u:playresponse>
</s:body>
</s:envelope>
-
Renderer(.92)告知PLAYING:
i1892 : 172.16.5.92:40036 > 172.16.5.90:1334, len:597
NOTIFY /a9e91358-f1d3-8081-6700-657b903a4cdf/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:db690087-714d-0ba5-fec8-7d19a4dbf60d
SEQ: 3
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1334
Content-Length: 318
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<transportstate val="PLAYING"></transportstate>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
i1896 : 172.16.5.90:1334 > 172.16.5.92:40036, len:111
HTTP/1.1 200 OK
Date: Fri, 08 Apr 2016 03:55:20 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
-
Renderer(.92)告知播放信息(时间等):
i6976 : 172.16.5.92:40036 > 172.16.5.90:1334, len:693
NOTIFY /a9e91358-f1d3-8081-6700-657b903a4cdf/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:db690087-714d-0ba5-fec8-7d19a4dbf60d
SEQ: 4
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1334
Content-Length: 429
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<numberoftracks val="1">
<currenttrack val="1">
<currenttrackduration val="00:04:45">
<currentmediaduration val="00:04:45"></currentmediaduration>
</currenttrackduration>
</currenttrack>
</numberoftracks>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
i6980 : 172.16.5.90:1334 > 172.16.5.92:40036, len:111
HTTP/1.1 200 OK
Date: Fri, 08 Apr 2016 03:55:21 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
...
2.5 事件
2.5.1 通用协议格式
订阅(Subscribing):
SUBSCRIBE publisher path HTTP/1.1
HOST: publisher host:publisher port
CALLBACK: <delivery URL>
NT: upnp:event
TIMEOUT: Second-requested subscription duration
响应Response:
HTTP/1.1 200 OK
DATE: when response was generated
SERVER: OS/version UPnP/1.0 product/version
SID: uuid:subscription-UUID
TIMEOUT: Second-actual subscription duration
- SID: Required. Subscription identifier. Must be the subscription identifier assigned by publisher in response to subscription request. Must be universally unique. Must begin with uuid:. Defined by UPnP vendor. Single URI.
事件通知(Eventing):
NOTIFY delivery path HTTP/1.1
HOST: delivery host:delivery port
CONTENT-TYPE: text/xml
CONTENT-LENGTH: Bytes in body
NT: upnp:event
NTS: upnp:propchange
SID: uuid:subscription-UUID
SEQ: event key
<!--?xml version="1.0"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<variablename>new value</variablename>
</e:property>
Other variable names and values (if any) go here.
</e:propertyset>
- NT: Required. Notification Type. Must be upnp:event.
- NTS: Required. Notification Sub Type. Must be upnp:propchange.
- SEQ: Required. Event key. Must be 0 for initial event message. Must be incremented by 1 for each event message sent to a particular subscriber. To prevent overflow, must be wrapped from 4294967295to 1. 32-bit unsigned value represented as a single decimal integer without leading zeroes (some implementations may include leading zeroes, which should be ignored by the recipient).
取消订阅:
UNSUBSCRIBE publisher path HTTP/1.1
HOST: publisher host:publisher port
SID: uuid:subscription UUID
2.5.2 订阅(Subscribing)/事件通知(Eventing)示例
2.5.2.1 AVTransport
Subscribing:
SUBSCRIBE /AVTransport/a44792d5-e283-2b1c-d4b7-0a1d06f5df27/event.xml HTTP/1.1
NT: upnp:event
CALLBACK: <http://172.16.5.90:1306/a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:AVTransport>
TIMEOUT: Second-1800
User-Agent: UPnP/1.0 DLNADOC/1.50 Kodi
Host: 172.16.5.92:1153
Response:
HTTP/1.1 200 OK
SID: uuid:fb5c0474-782f-b216-3cdd-c161d69d8dc6
TIMEOUT: Second-1800
Date: Wed, 13 Apr 2016 06:09:58 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
Eventing(起始播放时):
NOTIFY /a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:fb5c0474-782f-b216-3cdd-c161d69d8dc6
SEQ: 0
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1306
Content-Length: 3500
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<currentplaymode val="NORMAL">
<recordstoragemedium val="NOT_IMPLEMENTED">
<currenttrackuri val="">
<currenttrackduration val="00:00:00">
<currentrecordqualitymode val="NOT_IMPLEMENTED">
<currentmediaduration val="00:00:00">
<avtransporturi val="http://172.16.5.90:1191/%25/417D1D61A0DABEAADBADAC3C6806B811/amazing_spider_man_2.mp4">
<transportstate val="STOPPED">
<currenttrackmetadata val="">
<nextavtransporturi val="">
<possiblerecordqualitymodes val="NOT_IMPLEMENTED">
<currenttrack val="0">
<nextavtransporturimetadata val="">
<playbackstoragemedium val="NONE">
<currenttransportactions val="Play,Pause,Stop,Seek,Next,Previous">
<recordmediumwritestatus val="NOT_IMPLEMENTED">
<possibleplaybackstoragemedia val="NONE,NETWORK,HDD,CD-DA,UNKNOWN">
<avtransporturimetadata val="<DIDL-Lite
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
xmlns:sec="http://www.sec.co.kr/"
xmlns:xbmc="urn:schemas-xbmc-org:metadata-1-0/"><item
id="/media/f/avstream/mp4/amazing_spider_man_2.mp4"
parentID=""
restricted="1"><dc:title>amazing_spider_man_2</dc:title><dc:creator>Unknown</dc:creator><dc:date>2014-09-04</dc:date><dc:publisher>Unknown</dc:publisher><upnp:genre>Unknown</upnp:genre><upnp:albumArtURI
dlna:profileID="JPEG_TN">http://172.16.5.90:1191/%25/849BE949E91D458B577B57B2075DD85D/amazing_spider_man_2.mp4</upnp:albumArtURI><upnp:lastPlaybackTime>1601-01-01T00:00:00+21:36</upnp:lastPlaybackTime><upnp:playbackCount>0</upnp:playbackCount><upnp:episodeSeason>0</upnp:episodeSeason><res
duration="2:21:34.000" size="1425378294"
resolution="1280x720"
protocolInfo="http-get:*:video/mp4:DLNA.ORG_PN=MPEG4_P2_SP_AAC;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000">http://172.16.5.90:1191/%25/417D1D61A0DABEAADBADAC3C6806B811/amazing_spider_man_2.mp4</res><res
protocolInfo="xbmc.org:*:thumb:*">http://172.16.5.90:1191/%25/849BE949E91D458B577B57B2075DD85D/amazing_spider_man_2.mp4</res><xbmc:dateadded>1601-01-01</xbmc:dateadded><xbmc:rating>0.0</xbmc:rating><xbmc:artwork
type="thumb">http://172.16.5.90:1191/%25/849BE949E91D458B577B57B2075DD85D/amazing_spider_man_2.mp4</xbmc:artwork><upnp:class>object.item.videoItem</upnp:class></item></DIDL-Lite>">
<numberoftracks val="0">
<possiblerecordstoragemedia val="NOT_IMPLEMENTED">
<transportstatus val="OK">
<transportplayspeed val="1"></transportplayspeed>
</transportstatus>
</possiblerecordstoragemedia>
</numberoftracks>
</avtransporturimetadata>
</possibleplaybackstoragemedia>
</recordmediumwritestatus>
</currenttransportactions>
</playbackstoragemedium>
</nextavtransporturimetadata>
</currenttrack>
</possiblerecordqualitymodes>
</nextavtransporturi>
</currenttrackmetadata>
</transportstate>
</avtransporturi>
</currentmediaduration>
</currentrecordqualitymode>
</currenttrackduration>
</currenttrackuri>
</recordstoragemedium>
</currentplaymode>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
Response:
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2016 06:09:43 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
Eventing(TRANSITIONING):
NOTIFY /a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:fb5c0474-782f-b216-3cdd-c161d69d8dc6
SEQ: 1
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1306
Content-Length: 2534
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<avtransporturi val="http://172.16.5.90:1191/%25/FD5D04760DCC122162D0CDEA0FECD3B3/alan.mp4">
<avtransporturimetadata val="<DIDL-Lite
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
xmlns:sec="http://www.sec.co.kr/"
xmlns:xbmc="urn:schemas-xbmc-org:metadata-1-0/"><item
id="/media/f/avstream/mp4/alan.mp4"
parentID=""
restricted="1"><dc:title>alan</dc:title><dc:creator>Unknown</dc:creator><dc:date>2013-01-07</dc:date><dc:publisher>Unknown</dc:publisher><upnp:genre>Unknown</upnp:genre><upnp:albumArtURI
dlna:profileID="JPEG_TN">http://172.16.5.90:1191/%25/73D7D987DD67085B244D64E912BE8C6C/alan.mp4</upnp:albumArtURI><upnp:lastPlaybackTime>2016-02-24T18:12:53+21:36</upnp:lastPlaybackTime><upnp:playbackCount>0</upnp:playbackCount><upnp:episodeSeason>0</upnp:episodeSeason><res
duration="0:02:33.000" size="37748317"
resolution="720x480"
protocolInfo="http-get:*:video/mp4:DLNA.ORG_PN=MPEG4_P2_SP_AAC;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000">http://172.16.5.90:1191/%25/FD5D04760DCC122162D0CDEA0FECD3B3/alan.mp4</res><res
protocolInfo="xbmc.org:*:thumb:*">http://172.16.5.90:1191/%25/73D7D987DD67085B244D64E912BE8C6C/alan.mp4</res><xbmc:dateadded>1601-01-01</xbmc:dateadded><xbmc:rating>0.0</xbmc:rating><xbmc:artwork
type="thumb">http://172.16.5.90:1191/%25/73D7D987DD67085B244D64E912BE8C6C/alan.mp4</xbmc:artwork><upnp:class>object.item.videoItem</upnp:class></item></DIDL-Lite>">
<transportstate val="TRANSITIONING"></transportstate>
</avtransporturimetadata>
</avtransporturi>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
Response:
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2016 06:09:59 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
Eventing(PLAYING):
NOTIFY /a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:fb5c0474-782f-b216-3cdd-c161d69d8dc6
SEQ: 2
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1306
Content-Length: 318
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<transportstate val="PLAYING"></transportstate>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
Response:
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2016 06:10:00 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
Eventing(STOPPED):
NOTIFY /a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:AVTransport HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:fb5c0474-782f-b216-3cdd-c161d69d8dc6
SEQ: 4
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1306
Content-Length: 466
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">
<instanceid val="0">
<transportstate val="STOPPED">
<numberoftracks val="0">
<currenttrack val="0">
<currenttrackduration val="00:00:00">
<currentmediaduration val="00:00:00"></currentmediaduration>
</currenttrackduration>
</currenttrack>
</numberoftracks>
</transportstate>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
Response:
略
2.5.2.2 ConnectionManager
Subscribing:
SUBSCRIBE /ConnectionManager/a44792d5-e283-2b1c-d4b7-0a1d06f5df27/event.xml HTTP/1.1
NT: upnp:event
CALLBACK: <http://172.16.5.90:1306/a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:ConnectionManager>
TIMEOUT: Second-1800
User-Agent: UPnP/1.0 DLNADOC/1.50 Kodi
Host: 172.16.5.92:1153
Response:
HTTP/1.1 200 OK
SID: uuid:0c8245e4-a6b8-5a5d-d7f3-e2004bca123f
TIMEOUT: Second-1800
Date: Wed, 13 Apr 2016 06:09:58 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
Eventing:
NOTIFY /a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:ConnectionManager HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:0c8245e4-a6b8-5a5d-d7f3-e2004bca123f
SEQ: 0
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1306
Content-Length: 2929
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<sourceprotocolinfo>
</sourceprotocolinfo>
</e:property>
<e:property>
<sinkprotocolinfo>http-get:*:video/mp4:DLNA.ORG_PN=MPEG4_P2_SP_AAC,
http-get:*:video/mp4:DLNA.ORG_PN=AVC_MP4_BL_L3L_SD_AAC,
http-get:*:video/x-ms-asf:DLNA.ORG_PN=MPEG4_P2_ASF_ASP_L4_SO_G726,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_PRO,
http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN,
http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMAFULL,
http-get:*:video/x-ms-asf:DLNA.ORG_PN=VC1_ASF_AP_L1_WMA,
http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM,
http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_BASE,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVSPML_MP3,
http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMABASE,
http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_PAL,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_FULL,
http-get:*:image/png:DLNA.ORG_PN=PNG_LRG,
http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_PAL_XAC3,
http-get:*:video/mp4:DLNA.ORG_PN=AVC_MP4_MP_HD_1080i_AAC,
http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED,
http-get:*:video/x-ms-asf:DLNA.ORG_PN=MPEG4_P2_ASF_SP_G726,
http-get:*:audio/L16;rate=48000;channels=2:DLNA.ORG_PN=LPCM,
http-get:*:audio/mpeg:DLNA.ORG_PN=MP3,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_PRO,
http-get:*:video/mp4:DLNA.ORG_PN=AVC_MP4_HP_HD_AAC,
http-get:*:audio/mpeg:DLNA.ORG_PN=MP3X,
http-get:*:video/x-ms-asf:DLNA.ORG_PN=MPEG4_P2_ASF_ASP_L5_SO_G726,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVSPLL_BASE,
http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC,
http-get:*:video/mpeg:DLNA.ORG_PN=MPEG1,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVSPML_BASE,
http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_FULL,
http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMAPRO,
http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG,
http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC_XAC3,
http-get:*:audio/L16;rate=44100;channels=1:DLNA.ORG_PN=LPCM,
http-get:*:image/x-ycbcr-yuv420:*,
http-get:*:video/x-ms-wmv:*,
http-get:*:audio/x-ms-wma:*,
http-get:*:video/mp4:*,
http-get:*:video/avi:*,
http-get:*:video/quicktime:*,
http-get:*:video/wtv:*,
rtsp-rtp-udp:*:video/x-ms-asf:DLNA.ORG_PN=MPEG4_P2_ASF_SP_G726,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_PRO,
rtsp-rtp-udp:*:video/x-ms-asf:DLNA.ORG_PN=MPEG4_P2_ASF_ASP_L5_SO_G726,
rtsp-rtp-udp:*:video/x-ms-asf:DLNA.ORG_PN=MPEG4_P2_ASF_ASP_L4_SO_G726,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVSPLL_BASE,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVSPML_BASE,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_PRO,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_FULL,
rtsp-rtp-udp:*:video/x-ms-asf:DLNA.ORG_PN=VC1_ASF_AP_L1_WMA,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_BASE,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_FULL,
rtsp-rtp-udp:*:video/x-ms-wmv:DLNA.ORG_PN=WMVSPML_MP3,
rtsp-rtp-udp:*:video/x-ms-wmv:*</sinkprotocolinfo>
</e:property>
<e:property>
<currentconnectionids>0</currentconnectionids>
</e:property>
</e:propertyset>
i112 : 172.16.5.92:1153 > 172.16.5.90:51264, len:194
HTTP/1.1 200 OK
SID: uuid:57b029f1-db42-1aa4-d9a4-d8275d513f18
TIMEOUT: Second-1800
Date: Wed, 13 Apr 2016 06:09:58 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
Response:
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2016 06:09:43 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi
2.5.2.3 RenderingControl
Subscribing:
SUBSCRIBE /RenderingControl/a44792d5-e283-2b1c-d4b7-0a1d06f5df27/event.xml HTTP/1.1
NT: upnp:event
CALLBACK: <http://172.16.5.90:1306/a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:RenderingControl>
TIMEOUT: Second-1800
User-Agent: UPnP/1.0 DLNADOC/1.50 Kodi
Host: 172.16.5.92:1153
Response:
HTTP/1.1 200 OK
SID: uuid:57b029f1-db42-1aa4-d9a4-d8275d513f18
TIMEOUT: Second-1800
Date: Wed, 13 Apr 2016 06:09:58 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
Eventing:
NOTIFY /a44792d5-e283-2b1c-d4b7-0a1d06f5df27/urn:upnp-org:serviceId:RenderingControl HTTP/1.1
NT: upnp:event
NTS: upnp:propchange
SID: uuid:57b029f1-db42-1aa4-d9a4-d8275d513f18
SEQ: 0
User-Agent: Neptune/1.1.3
Host: 172.16.5.90:1306
Content-Length: 448
Content-Type: text/xml; charset="utf-8"
<!--?xml version="1.0" encoding="UTF-8"?-->
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<lastchange>
<event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/">
<instanceid val="0">
<volume
channel="Master"
val="100">
<mute
channel="Master"
val="0">
<presetnamelist val="FactoryDefaults">
<volumedb
channel="Master"
val="0"></volumedb>
</presetnamelist>
</mute>
</volume>
</instanceid>
</event>
</lastchange>
</e:property>
</e:propertyset>
Response:
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2016 06:09:43 GMT
Content-Length: 0
Server: UPnP/1.0 DLNADOC/1.50 Kodi