DNLA自学(二) Device 设备描述

接下来是如何识别设备了
注释:没有添加注释的节点 建议保持默认值
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:dlna="urn:schemas-dlna-org:device-1-0" xmlns:sec="http://www.sec.co.kr/dlna" xmlns="urn:schemas-upnp-org:device-1-0">
   <specVersion>
      <major>1</major>
      <minor>0</minor>
   </specVersion>
   <device>
      <dlna:X_DLNADOC>DMS-1.50</dlna:X_DLNADOC>
      <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>
      <INMPR03>1.0</INMPR03>
      <friendlyName>TG</friendlyName>                                        //设备名称 可自定义
      <manufacturer>OpenSource</manufacturer>                                //厂家     可自定义
      <modelDescription>Media Service Device</modelDescription>              //模块描述 可自定义
      <modelName>Media Service</modelName>                                   //模块名称 可自定义
      <modelNumber>OpenSource 2.0</modelNumber>                              //模块号   可自定义
      <modelURL>http://www.sourceforge.org/</modelURL>                       //模块网址 可自定义
      <UDN>uuid:9210c6a8-ad73-46ec-ba84-bf426b9f9f7e</UDN>                  
      <iconList>                                                             //图标信息 用于客户端显示设备
         <icon>
            <mimetype>image/png</mimetype>                                   //图片类型
            <width>1024</width>                                              //宽度
            <height>768</height>                                             //高度
            <depth>24</depth>                                                //颜色位数
            <url>/icon.png</url>                                             //链接地址 不包含HOST
         </icon>
         <icon>
            <mimetype>image/jpg</mimetype>
            <width>1024</width>
            <height>768</height>
            <depth>24</depth>
            <url>/icon.jpg</url>
         </icon>
         <icon>
            <mimetype>image/png</mimetype>
            <width>1024</width>
            <height>768</height>
            <depth>24</depth>
            <url>/icon2.png</url>
         </icon>
         <icon>
            <mimetype>image/jpg</mimetype>
            <width>1024</width>
            <height>768</height>
            <depth>24</depth>
            <url>/icon2.jpg</url>
         </icon>
      </iconList>
      <serviceList>                                                                            //服务列表  ConnectionManager和ContentDirectory 为基本服务
         <service>
            <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>        //服务类型
            <serviceId>urn:schemas-upnp-org:service:ConnectionManager</serviceId>              //服务id
            <SCPDURL>_urn-schemas-upnp-org-service-ConnectionManager_scpd.xml</SCPDURL>        //controlURL和eventSubURL接口描述
            <controlURL>_urn-schemas-upnp-org-service-ConnectionManager_control</controlURL>   //服务接口
            <eventSubURL>_urn-schemas-upnp-org-service-ConnectionManager_event</eventSubURL>   //事件订阅接口
         </service>
         <service>
            <serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType>
            <serviceId>urn:schemas-upnp-org:service:ContentDirectory</serviceId>
            <SCPDURL>_urn-schemas-upnp-org-service-ContentDirectory_scpd.xml</SCPDURL>
            <controlURL>_urn-schemas-upnp-org-service-ContentDirectory_control</controlURL>
            <eventSubURL>_urn-schemas-upnp-org-service-ContentDirectory_event</eventSubURL>
         </service>
      </serviceList>
   </device>
</root>
 
 
DMS(MediaServer) 必须包含ContentDirectory 和 ConnectionManager服务
DMP(AVRenderer) 必须包含ConnectionManager、RenderingControl和AVTransport服务
 
后面的文章主要介绍接口API,不再介绍接口调用和例子
 

“服务”调用的方法

请求:
注:
1、绿色部分换成服务相应的值
2、Browse为接口名称
3、pararms... 换成接口参数
POST /_urn-schemas-upnp-org-service-ContentDirectory_control HTTP/1.1
HOST: 192.168.0.106:47619
SOAPACTION: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"  //
CONTENT-TYPE: text/xml ; charset="utf-8"
 
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
        pararms...                                                              
      </u:Browse>
   </s:Body>
</s:Envelope>
 

调用例子:

请求:
POST /_urn-schemas-upnp-org-service-ContentDirectory_control HTTP/1.1
HOST: 192.168.0.106:47619
SOAPACTION: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"
CONTENT-TYPE: text/xml ; charset="utf-8"
 
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
         <ObjectID>0</ObjectID>
         <BrowseFlag>BrowseDirectChildren</BrowseFlag>
         <Filter>*</Filter>
         <StartingIndex>0</StartingIndex>
         <RequestedCount>15</RequestedCount>
         <SortCriteria />
      </u:Browse>
   </s:Body>
</s:Envelope>
 
响应:
HTTP/1.1 200  OK
CONTENT-TYPE:  text/xml; charset="utf-8"
EXT:  
SERVER:  Windows NT/5.0, UPnP/1.0
 
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
         <Result><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/">
  <container id="0000000000000004" searchable="0" parentID="0" restricted="1" childCount="1">
    <dc:title>Shared Dir</dc:title>
    <upnp:class>object.container</upnp:class>
    <upnp:writeStatus>UNKNOWN</upnp:writeStatus>
  </container>
</DIDL-Lite></Result>
         <NumberReturned>1</NumberReturned>
         <TotalMatches>1</TotalMatches>
         <UpdateID>1</UpdateID>
      </u:BrowseResponse>
   </s:Body>
</s:Envelope>

 

“事件订阅” 调用的方法

客户端请求:
SUBSCRIBE /_urn-schemas-upnp-org-service-ConnectionManager_event HTTP/1.1
NT: upnp:event
TIMEOUT: Second-300
HOST: 192.168.30.14:47187
//CALLBACK 为服务器推给客户端的数据,也就是说客户端需要 启动一个server用于接收
 
服务器响应:
HTTP/1.1 200 OK
TIMEOUT: Second-300
SID: uuid:0bd467b6-ad65-4873-a9b3-168bf7a987d2-urn:schemas-upnp-org:service:ConnectionManager-1
SERVER: Windows NT/5.0, UPnP/1.0

 

服务器推送的订阅

服务器推送:

NOTIFY /0bd467b6-ad65-4873-a9b3-168bf7a987d2/urn:schemas-upnp-org:service:ConnectionManager HTTP/1.1
CONTENT-TYPE: text/xml
SEQ: 0
HOST: 192.168.30.114:9558
NTS: upnp:propchange
SID: uuid:0bd467b6-ad65-4873-a9b3-168bf7a987d2-urn:schemas-upnp-org:service:ConnectionManager-1
CONNECTION: close
NT: upnp:event
 
<?xml version="1.0" encoding="utf-8"?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
   <e:property>
      <SinkProtocolInfo>192:168:30:14</SinkProtocolInfo>
   </e:property>
   <e:property>
      <SourceProtocolInfo>192:168:30:14</SourceProtocolInfo>
   </e:property>
   <e:property>
      <CurrentConnectionIDs>0</CurrentConnectionIDs>
   </e:property>
</e:propertyset>
 
客户端响应:
HTTP/1.1 200 OK





 
 










posted @ 2013-04-02 16:17  田径  阅读(1711)  评论(0编辑  收藏  举报
我的开源的地址https://github.com/tianjing/ 大家踊跃拍砖共同成长,拍砖的同时记得附上意见或者建议。!!谢谢 谢谢