Browse Source

dynamicly change the root device's xml description...

[git-p4: depot-paths = "//depot/": change = 719]
replace/5b80aeb26dc425aaddcd5182126c969e5cc04cbb
John-Mark Gurney 19 years ago
parent
commit
25dd7972fe
2 changed files with 28 additions and 17 deletions
  1. +15
    -7
      pymediaserv
  2. +13
    -10
      root-device.xml

+ 15
- 7
pymediaserv View File

@@ -6,6 +6,7 @@
# (c) 2005, Tim Potter <tpot@samba.org>

import random
import socket
import string
import sys
from twisted.python import log
@@ -37,6 +38,7 @@ port.joinGroup(SSDP_ADDR)
port.setLoopbackMode(0) # don't get our own sends

uuid = 'uuid:' + generateuuid()
urlbase = 'http://%s:%d/' % (listenAddr, listenPort)

# Create SOAP server

@@ -48,9 +50,15 @@ class WebServer(resource.Resource):
def __init__(self):
resource.Resource.__init__(self)

class RootDevice(static.File):
class RootDevice(static.Data):
def __init__(self):
static.File.__init__(self, 'root-device.xml', defaultType = 'text/xml')
r = {
'hostname': socket.gethostname(),
'uuid': uuid,
'urlbase': urlbase,
}
d = file('root-device.xml').read() % r
static.Data.__init__(self, d, 'text/xml')

root = WebServer()
root.putChild('ContentDirectory', ContentDirectoryServer())
@@ -69,23 +77,23 @@ reactor.listenTCP(listenPort, site)
# we need to do this after the children are there, since we send notifies
s.register('%s::upnp:rootdevice' % uuid,
'upnp:rootdevice',
'http://%s:%d/root-device.xml' % (listenAddr, listenPort))
urlbase + 'root-device.xml')

s.register(uuid,
uuid,
'http://%s:%d/root-device.xml' % (listenAddr, listenPort))
urlbase + 'root-device.xml')

s.register('%s::urn:schemas-upnp-org:device:MediaServer:1' % uuid,
'urn:schemas-upnp-org:device:MediaServer:1',
'http://%s:%d/root-device.xml' % (listenAddr, listenPort))
urlbase + 'root-device.xml')

s.register('%s::urn:schemas-upnp-org:service:ConnectionManager:1' % uuid,
'urn:schemas-upnp-org:device:ConnectionManager:1',
'http://%s:%d/root-device.xml' % (listenAddr, listenPort))
urlbase + 'root-device.xml')

s.register('%s::urn:schemas-upnp-org:service:ContentDirectory:1' % uuid,
'urn:schemas-upnp-org:device:ContentDirectory:1',
'http://%s:%d/root-device.xml' % (listenAddr, listenPort))
urlbase + 'root-device.xml')

# Main loop



+ 13
- 10
root-device.xml View File

@@ -4,32 +4,35 @@
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>%(urlbase)s</URLBase>
<device>
<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>
<INMPR03>1.0</INMPR03>
<friendlyName>Python Media Server</friendlyName>
<manufacturer>Zensonic</manufacturer>
<manufacturerURL>http://www.redsonic.com</manufacturerURL>
<modelDescription>UPnP/AV 1.0 Compliant Media Server</modelDescription>
<friendlyName>PyMedS (%(hostname)s)</friendlyName>
<manufacturer>JMGDIE</manufacturer>
<manufacturerURL>http://www.funkthat.com/</manufacturerURL>
<modelDescription>hopefully a UPnP/AV 1.0 Compliant Media Server</modelDescription>
<modelName>PC-MediaServer-DSM</modelName>
<modelNumber>103</modelNumber>
<serialNumber>0000001</serialNumber>
<UDN>uuid:XVKKBUKYRDLGJQDTPOT</UDN>
<modelNumber>1</modelNumber>
<modelURL>about:blank</modelURL>
<serialNumber>0</serialNumber>
<UDN>uuid:%(uuid)s</UDN>
<UPC/>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
<serviceId>urn:upnp-org:serviceId:CMGR_0-99</serviceId>
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
<SCPDURL>ConnectionManager/scpd.xml</SCPDURL>
<controlURL>ConnectionManager/control</controlURL>
<eventSubURL>ConnectionManager/event</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType>
<serviceId>urn:upnp-org:serviceId:CDS_0-99</serviceId>
<serviceId>urn:upnp-org:serviceId:ContenDirectory</serviceId>
<SCPDURL>ContentDirectory/scpd.xml</SCPDURL>
<controlURL>ContentDirectory/control</controlURL>
<eventSubURL>ContentDirectory/event</eventSubURL>
</service>
</serviceList>
<deviceList/>
</device>
</root>

Loading…
Cancel
Save