Couch Tv 1.5.2 is mainly a bugfix update that fixes a UPnP scanning error that only affects first time users of Couch Tv. This post goes into some technical detail but I thought it necessary to provide some insight into how this bug occurred and how it was fixed.
Couch Tv 1.5.2 has been submitted for review and an expedited review has been requested.
Update: Couch Tv 1.5.2 has been approved and is available for download.
Increasing numbers of people are seeing this when launching Couch Tv for the first time:
To see if I could replicate the experience first time users are getting, I decided to delete my development build off of my Tv and download a fresh copy from the AppStore. Boom at first launch I see the above error. The problem now is I can’t debug the AppStore version since debugging information is stripped before being uploaded to the AppStore.
I then deleted the AppStore copy and loaded the current development build and ran into the same problem but at least I can debug Couch Tv in Xcode and look at debug logging. Part of the scanning process involves Couch Tv sending a UDP packet to multicast address 239.255.255.250 port 1900 with the following payload:
M-SEARCH * HTTP/1.1\r\n
HOST:239.255.255.250:1900\r\n
MAN:\"ssdp:discover\"\r\n
ST:ssdp:all\r\n
MX:3\r\n\r\n
A UPnP server (Plex in this example) on the local network responds with the following data:
HTTP/1.1 200 OK
Location: http://192.168.3.4:32469/DeviceDescription.xml
Cache-Control: max-age=1800
Server: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.11
EXT:
USN: uuid:46ca2c9b-bfd7-a2a0-74fb-3d6491fd488c::urn:schemas-upnp-org:device:MediaServer:1
ST: urn:schemas-upnp-org:device:MediaServer:1
Date: Thu, 25 Feb 2016 15:25:23 GMT
This told me that the scanning was correct and that the Plex server was responding properly so the bug must be in validating the server information. The bug was actually introduced in version 1.5 when filtering out non media server UPnP servers such as networked receivers. And since scanning is typically done only the first time you launch Couch Tv (servers are cached afterwards), I didn’t see this bug until after I deleted Couch Tv and started over with no cached data.
Prior to 1.5, Couch Tv would detect multiple UPnP servers and connect to the first one that responded with the above information. I soon found out that many different devices use the DLNA protocol and needed a way to only connect to those servers who could actually serve video content.
So far as using SSDP for DLNA server discovery, I have found that only some (not all) DLNA servers respond to the query:
M-SEARCH * HTTP/1.1\r\n
HOST:239.255.255.250:1900\r\n
MAN:\"ssdp:discover\"\r\n
ST:ssdp:all\r\n
MX:3\r\n\r\n
and others respond to the query slightly modified:
M-SEARCH * HTTP/1.1\r\n
HOST:239.255.255.250:1900\r\n
ST: urn:schemas-upnp-org:device:MediaServer:1\r\n
MAN:\"ssdp:discover\"\r\n
MX:3\r\n\r\n
Changing the ST field from ssdp:all in the first query to urn:schemas-upnp-org:device:MediaServer:1 seems to make all the difference depending on the DLNA server.
Finally as part of this update, I added focus support on the video information screen, so the video poster responds to the user’s touch on the Tv remote:
Thanks for reading
http://obsessive.io/O