[Prev][Next][Index][Thread]

Re: how can I do this?



Jiang Tao writes:
> 
> Suppose I want to retrive a huge vedio file from
> web server and play it. I don't want to save it first
> on hard disk and then play it. What I want to
> do is set a  buffer, and when the buffer is full then
> to begin to play it, while playing, buffer will read new
> data from web server. 

This is of course the right way to do it. The traditional way of dumping
data to a local file before an external viewer can start using it is a lot
less elegant as it does not allow for progressive "display" or use of the 
data stream.

> I mean, I need to read part data from buffer and play it,
> and buffer will discard the data read and retrieve new data
> until buffer is full. It seems the HXParse module has
> a bug which is you must dump whole data into memory in one
> time.

This is a bug or a feature depending on how you look at it. The
HTXParse stream was written by H&kon in order to be used in Arena. Arean
uses a paint stream where instead of building a parse tree, it puts
pointers into the original data stream. In this case you need to
have the full data object in one dynamic data block at the same time.

Using a big buffer while reading input means that you have to copy data
which is always an expensive operation. Instead I suggest that you keep
a minimum buffer just enough to display, let's say one frame, and then
display it as soon as you can. I am not too familiar with video formats
but I guess that this must be possible.

If you already have a video display machine in place that does accept a 
stream of data then all you have to do is to write a Library stream
wrapper that turns this module into a Library converter. That way the
stream stack can find the converter based on the content type and you
will start receive data automatically when a video is downloaded.

It would be very nice if the video parser is independent of widget in which
it is operating so that you can use the parser on many platforms and then
have the specific widget handling the presentation.

I am of course _very_ interested in hearing about your results :-)

Henrik


Follow-Ups: References: