|Subject:||Re: Indy HTTP Server|
|Posted by:||Remy Lebeau \(Indy Team\) (email@example.com)|
|Date:||Tue, 28 Jul 2009|
"Eric" <firstname.lastname@example.org> wrote in message
> What I need to do is video streaming over HTTP
TIdHTTPServer does not natively support data streaming at this time. You
will have to implement it manually.
> The problem is that when we respond to the OnCommandGet
> event, we must put all the data there and respond
Exactly. So you will have to keep the current HTTP request/response active
for the lifetime of the streaming.
> I coudn´t find any place where I can get the connection
You can gain access to the Connection via the event's TIdPeerThread (Indy 9
and earlier) or TIdContext (Indy 10) parameter.
> keep it opened (After the OnCommandGet routine exit)
> and I keep sending data to this connection
There is no guarantee that the connection will be kept open. That is
negotiated between the server and client. Either party can close the
connection after the reply is sent. So you will have to make sure that all
of the streaming occuring while OnCommandGet is still running.
> because the video streaming is live, so, there is not fixed data to send,
> I´m sending video continously until the user breaks the connection
> Is there any way to do that?
You can assign the necessary response headers to AResponseInfo as needed (do
not assign the AResponseInfo.ContentLength, AResponseInfo.ContentText, or
AResponseInfo.ContentStream properties at all), then call
AResponseInfo.WriteHeader() to send just the headers to the client, and then
send your live video data afterwards as needed until the client disconnects
or the video ends, at which time you can then exit the OnCommandGet event
In order for such streaming to work correctly, the client must support data
chunking via the 'Transfer-Encoding: chunked' format, as outlined in RFC
2616 http://www.ietf.org/rfc/rfc2616.txt), Sections 3.6 and 3.6.1.
Remy Lebeau (TeamB)
Indy HTTP Server posted by Eric on Mon, 27 Jul 2009