End of File
From pyTivo - Wiki
Years ago TiVo appeared to be taking a path of cooperative development with the open source community. With the release of the HMO protocol and the HME SDK it appeared that TiVo was trying to encourage third party noncommercial development for TiVo. However since the TiVo sponsored competition for HME products there has been no further support or encouragement from TiVo. There has been no update to the SDK yet, many updates and enhancements have been added to the HMO/HME protocols. My assumption is that TiVo is choosing to favor commercial developments and partnerships, most likely because they are in need of cash.
I however, believe they are taking the wrong path. I believe that by embracing the open source community TiVo can create many more features and benefits for TiVo owners and in turn sell more of their product. To that end it is my intention to provide what I have learned in working on pyTivo to the rest of the open source community so that they may avoid mistakes we have made. Most of the development of pyTivo comes from watching how TiVo's own products interact with the TiVo and reverse engineering our own similar solution.
How pyTivo Transfers Streamed Video
- TiVo asks for the information about a video
- This request is in the form of a webpage request
- pyTivo sends back a file size that is as large as the file could possibly be (Example 1Gig)
- This data is returned in an XML formated page
- TiVo sends a get request for the Video
- Again this is sent as an HTTP GET request
- pyTivo streams the video as it transcodes
- Stream abruptly ends at the end of the video (Example 800MB)
- ffmpeg has reached the end of the file and transcoding is complete. However because the size of the transcoded file always varies the end of file comes before the total number of bytes TiVo is expecting.
- So at this point TiVo is still expecting another 200MB
- TiVo waits thinking that network traffic has slowed down the packets, TiVo seems to wait 30 seconds or so.
- TiVo then requests the file again asking for the last 200MB.
- This request is sent in a second HTTP GET request, however this time TiVo request the range of the file it is still missing. In this case that would be 800MB - 1000MB.
- pyTivo responds with a 206 which tells TiVo that the file has ended and sends a short bit of code which I believe equals and End of File line.
- pyTivo receives the request and sees that the byte request is beyond the length of the file and is out of range.
- pyTivo then responds with an HTTP 206 response, partial content.
- This response contains headers stating that there is no more file and to close the connection.
- It tells TiVo specifically the range of bytes which it can forget about, in this case 800MB - 1000MB
- It sends back three hexadecimal characters in the body of the TCP packet. These are "300D0A" (ASCII "0" (zero) followed by CR-LF (end-of-line)). I have no idea what this means, I only saw it in responses from TiVo Desktop and copied it. My assumption is that this is an End of File signal? Without it TiVo will still recognize that the transfer was not interrupted, but the file will be deleted from the TiVo immediately, which makes me think that TiVo interprets the lack of those characters as a corrupt file.
Hope this helps anyone else out there trying to figure out this protocol. If I have mistakes please feel free to correct them.