A Python UPnP Media Server

README 3.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. This code is based upon code by Tim Potter.
  2. It is licensed under the MIT license at:
  3. http://opensource.org/licenses/mit-license.php
  4. I got a D-Link DSM-520 but I needed a UPnP Media Server to stream data
  5. with. I tried one, but it had issues running under FreeBSD's Linux
  6. emulation. Since I know Python, I went looking for a python server
  7. and found this code. The code was a good framework, so I expanded upon
  8. it.
  9. Tested devices and/or programs:
  10. Intel's Media Control Point and Media Renderer
  11. D-Link DSM-520
  12. The Intel tools are good for testing and are available at:
  13. http://www.intel.com/cd/ids/developer/asmo-na/eng/downloads/upnp/index.htm
  14. Either make a directory media and put the files there, or make a symlink
  15. named media to your media files. Either will work. Run it as:
  16. ./pymediaserv <localip> [ <http server port> ]
  17. Good Luck!
  18. John-Mark Gurney <gurney_j@resnet.uoregon.edu>
  19. Ideas for future improvements:
  20. Add res to the DVDTitle container to play the title, and for other
  21. containers that it makes sense for.
  22. Make the directory persistant so that the server's UUID can not
  23. change each run and we don't have to recreate the objects.
  24. Figure out how to rearchitect ContentDirectoryControl so I don't
  25. need to use doRecall. This may be helped by not necessarily
  26. figuring out all the children of a member just to fetch it.
  27. childCount isn't a required attribute.
  28. Autodetect IP address.
  29. Support sorting by other attributes.
  30. v0.x:
  31. Look inside MPEG-TS for TVCT and/or PAT and if there is more
  32. than one program, make it a container w/ the different
  33. programs.
  34. Add support for multiple res elements and automatic transcoding
  35. to either avi/xvid or mpeg2 using ffmpeg.
  36. Look inside DVDs and handle titles and chapters.
  37. Empty dirs w/ no content would disappear, and cause a short
  38. response to BrowseDirectChildren. The DSM-520 askes for one
  39. more than displayed, and uses the existant of the extra item
  40. as indication if there are more items.
  41. Understands zip and tar files now. It will dynamicly extract
  42. items, so you can zip up your jpegs and view them w/o having
  43. to unzip them. tar files can be gzip'd or bzip2'd.
  44. Each item now has an optinal content attribute, which if set is
  45. installed in the web server.
  46. Don't send 'foobar' when exiting, stops a traceback on another
  47. instance of PyMedS.
  48. v0.2:
  49. No longer require restarting to see new files/dirs in hierarchy.
  50. Add FSStorage which is a set of classes for handling filesystem
  51. objects, also handles updateID's.
  52. Make the root container customizable, so you don't end up with
  53. a single entry (like media) at the root. This lets us use a
  54. FSDirectory as the root and get auto-enumeration
  55. Support returning custom error codes, so that we can return 701
  56. No such object among others.
  57. Support deleting items, so we can remove them when no longer on
  58. the file system.
  59. Make Containers a subclass of list. This lets use populate
  60. childCount properly.
  61. Add required attributes to Storage* classes.
  62. Support custom container classes to addContainer.
  63. Add a few more custom mime-types.
  64. Sort listings by name for now.
  65. v0.1:
  66. Don't bind the UDP socket to the multicast address, so replies
  67. go out on our local IP.
  68. Send out notify requests when we register the services with SSDP.
  69. Send out byebye notifications when we are shutting down.
  70. Randomize the UUID for the server (this should be part of the
  71. saved state).
  72. Randomize the port, or optionally set it on the command line.
  73. Teach ContentDirectory.py the basics on handling Containers and
  74. generic browse support. You can addItem and addContainer, which
  75. each return either respective ObjectID.
  76. We already support partial chunking of responses, but we don't yet
  77. support filtering or sorting.