Archive for June 23rd, 2006
Sourceforge

By the way, Platinum 0.1.0.0 is now available on Sourceforge. Enjoy.

XBox + Windows Media Connect

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!