XBox + Windows Media Connect

Posted on June 23, 2006

I must be on a roll or something but tonite I was able to implement my multicast work around and I can now see more than 1 upnp servers. Check the result out.

So how does this workaround work? Well it’s quite easy. The xbox cannot send multicast so you need to specify which IP address the xbox should send the M-SEARCH packets to. That’s what you put in the XboxMediaCenter.xml Sources.xml as upnp://host:port.

The default port is not 1900 but 1901. The reason is that if you send a unicast udp packet to a port that is being used by multiple applications, only one will receive it wether or not they are expecting a multicast packet or not. So if you have multiple upnp apps on your host all listening on port 1900 for multicast packets, and you send unicastly instead of multicastly only one will receive it. Of course, most people don’t know but Windows has a service called SSDP which listens to 1900 and of course it’s the first one to receive the unicast packets that the xbox sends. So no other apps (UPnP Media Servers) running on Windows and not using this Service will not receive anything. Interestingly this Service is being used by all UPnP applications Microsoft comes out with, including Windows Media Connect. Go figure!
So now the proxy. By default, it has to listen on a different port than 1900 as explained above. So I chose 1901 but it’s configurable in the command line in case that port is ever going to be used by someone else. The proxy requires an exclusive access to the port (by binding it) to make sure it’s the only one listening on it to guarantee delivery. Of course remember to change the setting in the XboxMediaCenter.xml Sources.xml if you do change it.

When the proxy receives a SSDP unicast M-SEARCH from the xbox on port 1901 (or the one you specified), it creates a multicast socket and forwards the request to the regular UPnP address (239.255.255.250), and then waits for responses. Devices should respond to the proxy which then forwards back the responses to the xbox.

The proxy also listens for multicast announcement packets on port 1900. That way it can detect when a new UPnP device joins (or leaves) the network. When receiving a unicast request from the xbox, the proxy keeps around the ip address of the xbox and when multicast packets sent by UPnP devices are received by the proxy, it forwards them as well to the xbox (ip). It also works when devices go away but unfortunately, I have no way to asynchronously notify xbmc to update the UI (yet).

I just need to get the timeout working with blocking sockets which G. said he would add to Neptune soon.

I talked to spiff tonite again, I am going to publish all that tomorrow. Cheers!

3 Responses to “XBox + Windows Media Connect”

  1. XBMCfanboy
    Jul 03, 2006

  2. XBMCfanboy
    Jul 03, 2006

    the XBMS (Xbox Media Stream Protocol) client in XBMC supports auto-discovery of XBMS servers (a.k.a. ccXStream, a.k.a. XStream Servers) by using broadcast, (kind of like a DHCP server and client works).

    I think it works like this; the XBMS servers is constantly listening to a specific network port, when the user clicks the share in XBMS the client (built-into XBMC) sends out a broadcast on the network on that same port asking “are there any XBMS servers out there?”, all and any XBMS servers then reply “yes you can find me on IP-address xxx.xxx.xxx.xxx” and so the client recieved that and saves/caches that IP-address for that session.

    It can also work the other way around; meaning that the XBMS server is broadcasting on a specific port for example once every second saying “I’m an XBMS server and you can find me on IP-address xxx.xxx.xxx.xxx” but that is not very smart as you are then kind of spamming the network and it is also a security risc.

    More info on the XBMS protocol can be found in the CVS source code (for the client-side) and here on the server-side source code:
    http://prdownloads.sourceforge.net/xbmc/ccxstream-1.0.15.tar.gz
    http://prdownloads.sourceforge.net/xbmc/ccxstream-1.0.15-win.rar
    http://sourceforge.net/projects/mfxstream
    http://sourceforge.net/projects/pxbmsps


  3. Tat3r
    Jul 03, 2006

    Any chance of releasing the source code for your SSDP proxy application/service?, preferably in C language if possible. I would love to be able to port it to Linux, UNIX or BSD. Be very cool if could run it on a other little server or device that is running all the time, I for example have FreeNAS (which is based on FreeBSD) running on a VIA MiniITX computer that I have a couple of large harddrives in for audio and video streaming that is on 24/7. A few friends of mine who also use XBMC run Linux based firewalls/routers at home which is running 24/7 anyway so those be great to have a SSDP proxy deamon installed on. Todat also many retail routers from LinkSys and D-Link run some kind of Linux or other operating system for which you can compile your own small apps and run on as well.



Leave a Reply

Categories

Archives