Board index » delphi » count streamed bytes from an http server

count streamed bytes from an http server

I'm trying to stream an audio file to an audio player applet (for "tech
talk" lectures that are recorded here and offered to the staff).  What I
wanted to do was to track how much of the audio stream was sent to each
client.  If they cut out halfway through the lecture, then I can
indicate on a statistics page how long the lecture lasted before people
lost interest.  I'm using Indy components.
-W
 

Re:count streamed bytes from an http server


Quote
"Walter Mitty" <w...@mitty.com> wrote in message

news:3BED9B00.10306@mitty.com...

Quote
> What I
> wanted to do was to track how much of the audio stream was sent to each
> client.
> I'm using Indy components.

Are you using TCP or UDP for stream transmission?

TCP will get an OnWork event when buffers are read from the connection.  UDP
should have some type of marker in the stream to identify the current buffer
segment.

In either case, these will not indicate where a playback device (like
PlaySound) was stopped.  Just the amount of data requested prior to the
device being stopped.

This sounds like an interesting app (pun intended).<g>  Have you considered
submitting it as an Indy demo?

Re:count streamed bytes from an http server


Don Siders - Team Indy wrote:

Quote
> Are you using TCP or UDP for stream transmission?

The client applet is using http get (and starts downloading the sound
file), so that would be TCP, right?
I'm a bit new to the "nitty gritty" of Internet protocols.

Quote
> TCP will get an OnWork event when buffers are read from the connection.  UDP should have some type of marker in the stream to identify the current buffer
> segment.

How would I hook into that?  I wouldn't know how to track that using the
IdHTTPServer component.

Quote
> In either case, these will not indicate where a playback device (like
> PlaySound) was stopped.  Just the amount of data requested prior to the
> device being stopped.

I see what you mean.  The applet buffers on the client end, so if
someone stops at 60 seconds, the amount of data that the server has sent
may equal 80 seconds.

Quote

> This sounds like an interesting app (pun intended).<g>  Have you considered
> submitting it as an Indy demo?

Sure.  Just got to make it work.
-WM

Re:count streamed bytes from an http server


[This followup was posted to borland.public.delphi.internet.winsock and a
copy was sent to the cited author.]

In article <3BEE0C9E.8050...@mitty.com>, w...@mitty.com says...

Quote

> Don Siders - Team Indy wrote:

> > Are you using TCP or UDP for stream transmission?

> The client applet is using http get (and starts downloading the sound
> file), so that would be TCP, right?

Yes, it would be TCP.  

Quote
> I'm a bit new to the "nitty gritty" of Internet protocols.

Try looking at Kudzu's article "Introduction to sockets".  The URL is:

http://www.pbe.com/Kudzu/Articles/IntroToSockets/ .

Quote

> > TCP will get an OnWork event when buffers are read from the connection.  UDP should have some type of marker in the stream to identify the current buffer
> > segment.

> How would I hook into that?  I wouldn't know how to track that using the
> IdHTTPServer component.

Okay.  Every connection to the server is in a thread (TIdPeerThread).  
TIdPeerThread has a property called Connection which is a
TIdTCPServerConnection.  This is a direct anscestor of TIdTCPConnection
(another anscestor is TIdTCPClient).  The Connection object just like the
clients have an OnWork event.  You can set event handlers in the
TIdTCPServer.OnConnect event for the thread's Connection object.  One
thing to be careful about is that your event tracking code must be 100%
thread safe because it will be running in the context of the peer
connection thread and not the main-VCL thread.

--
Support the anti-Spam amendment - Join at http://www.cauce.org/
J. Peter Mugaas     E-Mail:  oma00...@mail.wvnet.edu
http://wvnvm.wvnet.edu/~oma00215/  ICQ Number:  14297043
Finger for PGP Key

Other Threads