UPnP Server Connection Basic tutorial

2010-06-14
2013-05-02
  • MrMMatricks

    MrMMatricks - 2010-06-14

    Hi!

    Maybe i'm blind but i can't find a simple example how to connect to a UPnP server.
    All i'm looking for is a code to list all songs in it's library. Later on i want to stream a song. But for the moment i would be happy to see code to connect to a server and simply list all songs. Or is that way harder than i think at the moment?

    Java preferred, but any other language would do.

    thanks!
    MrM

     
  • razvanc

    razvanc - 2010-06-14

    There are two different UPNP devices. One is a content server and the other something else, I don't remember - see the upnp A/V specification.

    Anyways, here's some very messy test code of mine, in Scala and Java - look at the bottom. It basically finds a TVersity server in my home network and starts browsing its content.

    http://github.com/razie/razupnp/blob/master/src/razie/upnp/UpnpInventory.scala

    Sorry about the mess - I left it in testing stage and I don't know when I'll come back to it.

     
  • razvanc

    razvanc - 2010-06-14

    I looked at it and remembered what's going on. The relevant piece of code is this:

    def Browse(ObjectId: String , BrowseFlag:String, StartingIndex:String, RequestedCount:String) = {
          val directory = actual.services.filter (_.serviceType == "urn:schemas-upnp-org:service:ContentDirectory:1").head
          val action = directory.actions.filter (_.name == "Browse").head
          action.inArgs.setAttr("ObjectID", ObjectId, "BrowseFlag", BrowseFlag, "StartingIndex", StartingIndex, "RequestedCount", RequestedCount)  
          action.execute
          val aa = action.outArgs
          action
       }

    in the device, you'll find services and they have actions - all from cyber link's library - I had some Scala wrappers to make it easy. Find the "Browse" action and just invoke it…

     
  • MrMMatricks

    MrMMatricks - 2010-06-15

    Hi!

    Didn't know Scala until now :]

    This code is perfectly what i was looking for! Thanks! Works like a charm.

    Now i only have to find out why my XBMC just shows a empty library (Does the same in all other UPnP controlpoints except the XBMC remote).

    Thanks a lot!
    MrM

     
  • MrMMatricks

    MrMMatricks - 2010-06-21

    Ok!

    Connection & Browsing works perfectly now!
    Anyone a tutorial how to get streaming kicking in? I just need audio streaming. Do i need to set up my own MediaRenderer Device for that or is it possible without (i don't need to remote remote control it etc.)?

    Thanks
    MrM

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks