Apple provides HTTP Streaming by breaking apart an MPEG file into segments based upon time. These segments much break on specific boundaries. The ability to do this is provided thru the use of an open source segmenting tool.
What we need is a variation of this tool, in a .NET class. The source code for the open source segmented is below, as well as an overview of how things work currently. This is provided so you can get a good understanding. What we need is slightly different.
What we are in need of is a .NET class which provides us the file/position (byte number), each time a SEGMENT would be made. As well, the file we will be using will be a LIVE active file being created. So while the segmenter source below would exit/complete at the end of the file, our class will continue to wait for more bytes in the file, when they exist - read, and process, and so on, until specifically told to stop. The way this class should work is as follows:
Function Init(filename as string) as Boolean = Return true if opened/false if not existent
. * One point here, the file needs to be opened in a manner which is SHARED, so that others apps writing to it are
. not affected, not apps opening it after will be affected
Subroutine Start - Starts the Processing
Property StopSize as long - A property we can set telling you the final byte of the file, where you can gracefully stop
Event Segment(int,long) - the int is a sequential counter each time this event is raised you increment it
. the long value is the byte index of the byte before segmenting
' In our class your not writing anything to a file, or creating a new files.
' You need only raise this event, we will handle the rest
Subroutine Stop - Stops Processing the File, raising Completed event as well with the last byte processed
Event ErroredOut(int,long) - Raises if an exception stopping you from processing occurs, int and long same as above
Event Completed(int,long) - Raised either from STOP or if you reached the position in StopSize
Property CurrentPosition as long = Current Byte Position you are currently at/processing
Thats it, so a lot code can be stripped from below, biggest piece here is doing it in MANAGED code (C++ Managed, or C++ with a C# Wrapper)
Source of Segmenter:
[login to view URL]
Overview:
[login to view URL]