diff --git a/DMS/ConnectionManager1.xml b/DMS/ConnectionManager1.xml new file mode 100644 index 0000000..201f1ad --- /dev/null +++ b/DMS/ConnectionManager1.xml @@ -0,0 +1,158 @@ + + + + 1 + 0 + + + + GetProtocolInfo + + + Source + SourceProtocolInfo + out + + + Sink + SinkProtocolInfo + out + + + + + GetCurrentConnectionIDs + + + ConnectionIDs + CurrentConnectionIDs + out + + + + + X_ChangeFriendlyName + + + FriendlyName + A_ARG_TYPE_FriendlyName + in + + + + + GetCurrentConnectionInfo + + + ConnectionID + A_ARG_TYPE_ConnectionID + in + + + RcsID + A_ARG_TYPE_RcsID + out + + + AVTransportID + A_ARG_TYPE_AVTransportID + out + + + ProtocolInfo + A_ARG_TYPE_ProtocolInfo + out + + + PeerConnectionManager + A_ARG_TYPE_ConnectionManager + out + + + PeerConnectionID + A_ARG_TYPE_ConnectionID + out + + + Direction + A_ARG_TYPE_Direction + out + + + Status + A_ARG_TYPE_ConnectionStatus + out + + + + + + + SourceProtocolInfo + string + http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_KO,http-get:*:audio/L16;rate=44100;channels=1:DLNA.ORG_PN=LPCM,http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM,http-get:*:audio/L16;rate=48000;channels=1:DLNA.ORG_PN=LPCM,http-get:*:audio/L16;rate=48000;channels=2:DLNA.ORG_PN=LPCM,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN + + + SinkProtocolInfo + string + + + + CurrentConnectionIDs + string + 0 + + + A_ARG_TYPE_FriendlyName + string + + + + A_ARG_TYPE_ConnectionStatus + string + + OK + ContentFormatMismatch + InsufficientBandwidth + UnreliableChannel + Unknown + + Unknown + + + A_ARG_TYPE_ConnectionManager + string + ok + + + A_ARG_TYPE_Direction + string + + Output + Input + + Output + + + A_ARG_TYPE_ProtocolInfo + string + + + + A_ARG_TYPE_ConnectionID + i4 + 0 + + + A_ARG_TYPE_AVTransportID + i4 + 0 + + + A_ARG_TYPE_RcsID + i4 + 0 + + + + diff --git a/DMS/ContentDirectory1.xml b/DMS/ContentDirectory1.xml new file mode 100644 index 0000000..8e97656 --- /dev/null +++ b/DMS/ContentDirectory1.xml @@ -0,0 +1,271 @@ + + + + 1 + 0 + + + + GetSystemUpdateID + + + Id + out + SystemUpdateID + + + + + GetSearchCapabilities + + + SearchCaps + out + SearchCapabilities + + + + + GetSortCapabilities + + + SortCaps + out + SortCapabilities + + + + + X_GetLocalPath + + + ObjectID + in + A_ARG_TYPE_ObjectID + + + LocalPath + out + A_ARG_TYPE_LocalPath + + + + + X_GetIndexfromRID + + + CategoryType + in + A_ARG_TYPE_CategoryType + + + RID + in + A_ARG_TYPE_RID + + + Index + out + A_ARG_TYPE_Index + + + + + X_GetObjectIDfromIndex + + + CategoryType + in + A_ARG_TYPE_CategoryType + + + Index + in + A_ARG_TYPE_Index + + + ObjectID + out + A_ARG_TYPE_ObjectID + + + + + X_BACKUP_START + + + X_BACKUP_DONE + + + SystemOff + in + A_ARG_TYPE_Index + + + + + X_SystemOff + + + Browse + + + ObjectID + in + A_ARG_TYPE_ObjectID + + + BrowseFlag + in + A_ARG_TYPE_BrowseFlag + + + Filter + in + A_ARG_TYPE_Filter + + + StartingIndex + in + A_ARG_TYPE_Index + + + RequestedCount + in + A_ARG_TYPE_Count + + + SortCriteria + in + A_ARG_TYPE_SortCriteria + + + Result + out + A_ARG_TYPE_Result + + + NumberReturned + out + A_ARG_TYPE_Count + + + TotalMatches + out + A_ARG_TYPE_Count + + + UpdateID + out + A_ARG_TYPE_UpdateID + + + + + CreateObject + + + ContainerID + in + A_ARG_TYPE_ObjectID + + + Elements + in + A_ARG_TYPE_Result + + + ObjectID + out + A_ARG_TYPE_ObjectID + + + Result + out + A_ARG_TYPE_Result + + + + + + + A_ARG_TYPE_SortCriteria + string + NULL + + + A_ARG_TYPE_UpdateID + ui4 + 0 + + + A_ARG_TYPE_Filter + string + NULL + + + A_ARG_TYPE_Result + string + NULL + + + A_ARG_TYPE_Index + ui4 + 0 + + + A_ARG_TYPE_ObjectID + string + NULL + + + SortCapabilities + string + + + + SearchCapabilities + string + + + + A_ARG_TYPE_Count + ui4 + 0 + + + A_ARG_TYPE_BrowseFlag + string + + BrowseMetadata + BrowseDirectChildren + + BrowseDirectChildren + + + SystemUpdateID + ui4 + 0 + + + A_ARG_TYPE_LocalPath + string + + + + A_ARG_TYPE_CategoryType + ui4 + + + + A_ARG_TYPE_RID + ui4 + + + + A_ARG_TYPE_Index + ui4 + + + + diff --git a/DMS/SamsungDmsDesc.xml b/DMS/SamsungDmsDesc.xml new file mode 100644 index 0000000..27e526f --- /dev/null +++ b/DMS/SamsungDmsDesc.xml @@ -0,0 +1,37 @@ + + + + 1 + 0 + + + DMS-1.50 + urn:schemas-upnp-org:device:MediaServer:1 + %(friendly_name)s + Samsung Electronics + http://www.samsung.com + Samsung PC AutoBackup + WiselinkPro + 1.0 + http://www.samsung.com + 20080818WiselinkPro + smi,DCM10,getMediaInfo.sec,getCaptionInfo.sec + uuid:%(uuid)s + + + urn:schemas-upnp-org:service:ContentDirectory:1 + urn:upnp-org:serviceId:ContentDirectory + /upnp/control/ContentDirectory1 + /upnp/event/ContentDirectory1 + ContentDirectory1.xml + + + urn:schemas-upnp-org:service:ConnectionManager:1 + urn:upnp-org:serviceId:ConnectionManager + /upnp/control/ConnectionManager1 + /upnp/event/ConnectionManager1 + ConnectionManager1.xml + + + + diff --git a/mediaserver.py b/mediaserver.py index 14323b3..d0ad991 100644 --- a/mediaserver.py +++ b/mediaserver.py @@ -41,44 +41,6 @@ ''' -DMS_DESC_RESPONSE = ''' - - - 1 - 0 - - - DMS-1.50 - urn:schemas-upnp-org:device:MediaServer:1 - %(friendly_name)s - Samsung Electronics - http://www.samsung.com - Samsung PC AutoBackup - WiselinkPro - 1.0 - http://www.samsung.com - 20080818WiselinkPro - smi,DCM10,getMediaInfo.sec,getCaptionInfo.sec - uuid:%(uuid)s - - - urn:schemas-upnp-org:service:ContentDirectory:1 - urn:upnp-org:serviceId:ContentDirectory - /upnp/control/ContentDirectory1 - /upnp/event/ContentDirectory1 - ContentDirectory1.xml - - - urn:schemas-upnp-org:service:ConnectionManager:1 - urn:upnp-org:serviceId:ConnectionManager - /upnp/control/ConnectionManager1 - /upnp/event/ConnectionManager1 - ConnectionManager1.xml - - - -''' - class Backup(object): @@ -145,17 +107,24 @@ self.config = common.LoadOrCreateConfig() def render_GET(self, request): + self.logger.debug('[%s] GET request for %s', request.getClientIP(), + request.path) self.logger.debug('Request args for %s from %s: %s', request.path, request.getClientIP(), request.args) self.logger.debug('Request headers for %s from %s: %s', request.path, request.getClientIP(), request.args) if request.path == '/DMS/SamsungDmsDesc.xml': - self.logger.info('New connection from %s (%s)', - request.getClientIP(), + self.logger.info('New connection from %s (%s)', request.getClientIP(), request.getHeader('user-agent')) self.clients[request.getClientIP()] = request.getHeader('user-agent') response = self.GetDMSDescriptionResponse() + elif request.path.split('/')[-1] == 'ContentDirectory1.xml': + with open(os.path.join('DMS', 'ContentDirectory1.xml'), 'r') as xml_data: + response = xml_data.read() + elif request.path.split('/')[-1] == 'ConnectionManager1.xml': + with open(os.path.join('DMS', 'ConnectionManager1.xml'), 'r') as xml_data: + response = xml_data.read() else: self.logger.error('Unhandled GET request from %s: %s', request.getClientIP(), request.path) @@ -227,9 +196,10 @@ return response def GetDMSDescriptionResponse(self): - response = DMS_DESC_RESPONSE % { - 'friendly_name': self.config.get('AUTOBACKUP', 'server_name'), - 'uuid': self.config.get('AUTOBACKUP', 'uuid')} + with open(os.path.join('DMS', 'SamsungDmsDesc.xml'), 'r') as dms_desc: + response = dms_desc.read() % { + 'friendly_name': self.config.get('AUTOBACKUP', 'server_name'), + 'uuid': self.config.get('AUTOBACKUP', 'uuid')} return response diff --git a/pc_autobackup.py b/pc_autobackup.py index eb3b4e9..f4b9307 100755 --- a/pc_autobackup.py +++ b/pc_autobackup.py @@ -221,7 +221,7 @@ resource = mediaserver.MediaServer() factory = Site(resource) - reactor.listenMulticast(1900, ssdp.SSDPServer()) + reactor.listenMulticast(1900, ssdp.SSDPServer(), listenMultiple=True) logger.info('SSDPServer started') reactor.listenTCP(52235, factory) logger.info('MediaServer started') diff --git a/ssdp.py b/ssdp.py index ba23ee2..c298c97 100644 --- a/ssdp.py +++ b/ssdp.py @@ -106,7 +106,7 @@ def StartSSDPServer(): logging.info('SSDPServer started') - reactor.listenMulticast(1900, SSDPServer()) + reactor.listenMulticast(1900, SSDPServer(), listenMultiple=True) reactor.run()