Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ioan
Roku Guru

Stand alone server for Roku

I'm trying to build a standalone server for Roku that will stream content from my local computer and I run into a problem (I'm using Delphi for development).
If I send the whole video as a stream, Roku will play the video nice to about minute 30 and then won't work anymore. If I stream the same video from Apache server, the video will play without problems...
I looked in Apache logs and I see that Roku makes multiple requests for the same video:

192.168.1.137 - - [05/Feb/2011:14:42:44 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679867904
192.168.1.137 - - [05/Feb/2011:14:45:16 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679169301
192.168.1.137 - - [05/Feb/2011:14:46:41 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679835136
192.168.1.137 - - [05/Feb/2011:14:47:57 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679136533
192.168.1.137 - - [05/Feb/2011:14:50:46 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679802368
192.168.1.137 - - [05/Feb/2011:14:51:17 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679070997
192.168.1.137 - - [05/Feb/2011:14:53:50 -0800] "GET /dvr/Bear%20Attack!/Bear%20Attack!_20110126_18001900.mp4 HTTP/1.1" 500 679769600


Can someone please explain to me, just in few words how the communication between Roku and the server should be handled? I need a good simple explanation 🙂

My first atempt, that plays about 30 min into the video looks like this on the sever side:

if FileExists(LFilename) then
begin
AResponseInfo.ContentType := 'video/mp4';
AResponseInfo.ContentStream := TIdReadFileExclusiveStream.Create(LFilename);
end;


TIA

P.S.: This is going to be open source, so anyone can play with it when I have a working version.
https://github.com/e1ioan/
http://rokucam.com
0 Kudos
18 REPLIES 18
greubel
Visitor

Re: Stand alone server for Roku

Your server needs to be able to handle partial transfers and addressing over 2 gig.
The format of mpeg movies is such that Roku needs to randomly access the video container to get parameters and data locations.
0 Kudos
kbenson
Visitor

Re: Stand alone server for Roku

The Roku seems to use open ended range requests with a reset of that connection after it receives a chunk of data it deems appropriate. It will then send another open ended range request beginning where it last got data from.

P.S. I may be way off on this, but that seems to be what I remember from testing and examining packet captures.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
ioan
Roku Guru

Re: Stand alone server for Roku

"greubel" wrote:
Your server needs to be able to handle partial transfers and addressing over 2 gig.
The format of mpeg movies is such that Roku needs to randomly access the video container to get parameters and data locations.


How does Roku requests a partial transfer? Do you have a request example (request header), and what should the server answer to that request?
https://github.com/e1ioan/
http://rokucam.com
0 Kudos
TheEndless
Channel Surfer

Re: Stand alone server for Roku

"ioan" wrote:
"greubel" wrote:
Your server needs to be able to handle partial transfers and addressing over 2 gig.
The format of mpeg movies is such that Roku needs to randomly access the video container to get parameters and data locations.

How does Roku requests a partial transfer? Do you have a request example (request header), and what should the server answer to that request?

It uses the Range header...
Range: bytes=0-1024
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
ioan
Roku Guru

Re: Stand alone server for Roku

"TheEndless" wrote:

It uses the Range header...
Range: bytes=0-1024


... and the server should answer with a chunk of the video for this range, just like if that chunk is the whole video, right?
https://github.com/e1ioan/
http://rokucam.com
0 Kudos
TheEndless
Channel Surfer

Re: Stand alone server for Roku

<removed to avoid confusion>
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
greubel
Visitor

Re: Stand alone server for Roku

You can also get
Range=bytes=25057-

That would be from 25057 to the end of the file.
Roku makes multiple requests like this and also full file transfers BUT he often kills the connect after he gets the data he needs.
So you might only transfer a couple of K and then get a connection closed or broken pipe.

I always give 206 on a partial transfer.
0 Kudos
RokuMarkn
Visitor

Re: Stand alone server for Roku

You must return 206, not 200, when responding to a range request. This is standard -- see section 14.35 in the HTTP 1.1 spec. You can also return 416 if the requested range is completely outside the file (so no bytes would be returned).

--Mark
0 Kudos
ioan
Roku Guru

Re: Stand alone server for Roku

I did some debugging and I see that the first two requests from Roku are without range, they look like this:

User-Agent: Roku/DVP-2.9 (012.09E01529A)
GET /Ancient%20Aliens/Ancient%20Aliens_20110126_20002100.mp4 HTTP/1.1


then the first request that has Range looks like this:

User-Agent: Roku/DVP-2.9 (012.09E01529A)
Range: bytes=439275-
GET /Ancient%20Aliens/Ancient%20Aliens_20110126_20002100.mp4 HTTP/1.1


next few requests are without a range and then:

User-Agent: Roku/DVP-2.9 (012.09E01529A)
Range: bytes=1335144-
GET /Ancient%20Aliens/Ancient%20Aliens_20110126_20002100.mp4 HTTP/1.1


My question is, what should I respond to the requests without a range and what is the default buffer value for a range without end?

Thanks.
https://github.com/e1ioan/
http://rokucam.com
0 Kudos