21110_directshow_stream_source

所属分类:Pascal/Delphi编程
开发工具:Delphi
文件大小:338KB
下载次数:79
上传日期:2007-12-03 19:22:43
上 传 者selami
说明:  Delphi DirectShow lib code to use streaming media. Use these libs to make delphi faster.

文件列表:
main.dfm (42453, 2004-03-01)
main.pas (4784, 2004-10-25)
playstrm.dpr (237, 2004-03-01)
playstrm.exe (651776, 2004-10-25)
SrcFilter.dcu (23445, 2004-10-25)
SrcFilter.int (673, 2003-11-27)
SrcFilterD6.dcu (23106, 2004-10-25)
SrcFilterD7.dcu (23445, 2004-10-25)
SrcFilterD9.dcu (23974, 2005-01-16)

I wanted for a long time a way to play a media stream directly (not from a file). Here it is. It was quite challenging, but in the end you have a way to render a media stream without saving to a file; for example play a sound (any kind) or avi file directly from a resource stream. It fully supports compressed streams! The demo is compressing a file into a ZLib stream and playing it. The component is a filter with an output pin that should be rendered. It takes care of most common formats, but it may not be all; send a feedback when something is not working. It is based on DSPack; the declaration looks like this: type TCustomSrcFilter = class(TBCBaseFilter) protected public constructor Create(AStream : TStream; FwdOnly: boolean = false; const StreamSize: Int*** = 0); overload; constructor Create(AStream : IStream; FwdOnly: boolean = false; const StreamSize: Int*** = 0); overload; destructor Destroy; override; function GetPin(n: Integer): TBCBasePin; override; function GetPinCount: Integer; override; property OutPin : IPin read GetOutPin; function NonDelegatingRelease: Integer; override; stdcall; end; Internally it is using IStream interface, so the TStream is used via a StreamAdapter. FwdOnly is a flag that instructs the filter to treat the stream as forward only; it means all seek operations on a previous position will first perform a seek to the start then set the position. This is especially for ZLib implementation of streams, so there is no workaround needed to use a compressed stream! Some filters (avi parser) require the length of the stream (uncompressed). As implemented in ZLib, one can obtain the size only by setting successive positions and actually decompressing the stream; when the end is reached an error is raised. It will not break the code, but you might be misleaded when running from the debugger. It's better to use some kind of the wrapper and return a stored size when the stream is seek at the end. New: I already modified the component so you can pass the size of the stream in the constructor. If you don't know it, of course leave it to default and it will be determined as described. It is also possible to pass an approximation of the stream size; usually it's better to pass a bigger size. This value is used by the parser filter and I can't say exactly how it is used. One can simply build a dll with a generic direct show filter to use in other environments by registering and/or declaring some functions that create the filter. Have fun, Gabriel Corneanu gabrielcorneanu@nospam.yahoo.com

近期下载者

相关文件


收藏者