Network Streaming with Delphi | |
I'm sorry but I am unable to provide any information for Delphi 5.
Network Streaming with DelphiThe DirectShow filter used to create an ASF stream is the AsfWriter. This filter actually performs three basic functions: Converts the input stream into an ASF stream, writes the stream to a .ASF file and writes the stream to an Internet or LAN IP address.If you run the DSPack 'ASF Capture' demo (Delphi 6 & 7), two potential problems are immediately apparent. First, it seems to be impossible to stop it writing a file to the Hard Drive and, second, the video streamed to the network is very low resolution with a small image size. Selecting any resolution (profile) other than the default, results in the standard DirectShow fault procedure: The application crashes or produces a 'harsh' system error. Let's build a simple application and deal with these problems one at a time.
Begin the project by dropping a VideoWindow, FilterGraph and Filter onto the form and add a ComboBox in which we can list the video devices which are on our system. Remember to add DSUtil and DirectShow9 to the uses section.....
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DSPack, DSUtil, DirectShow9;
.... define VideoDev as type TSysDevEnum and then enumerate the system's video devices in the form's FormCreate procedure.
var Form1: TForm1; VideoDev: TSysDevEnum; implementation{$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin VideoDev:= TSysDevEnum.Create(CLSID_VideoInputDeviceCategory); if VideoDev.CountFilters > 0 then begin for i:= 0 to VideoDev.CountFilters - 1 do ComboBox1.Items.Add(VideoDev.Filters[i].FriendlyName); end; end; This should be familiar stuff to you if you've read my DirectShow & Delphi tutorial. If not, I would recommend reading that tutorial first. We can set up the VideoWindow Preview in the ComboBox's OnSelect event handler.
procedure TForm1.ComboBox1Select(Sender: TObject); begin if FilterGraph1.Active then FilterGraph1.Active:= False; FilterGraph1.ClearGraph; Filter1.BaseFilter.Moniker:= VideoDev.GetMoniker(ComboBox1.ItemIndex); FilterGraph1.Active:= True; VideoWindow1.FilterGraph:= FilterGraph1; Filter1.FilterGraph:= FilterGraph1; FilterGraph1.Mode:= gmCapture; with FilterGraph1 as ICaptureGraphBuilder2 do begin RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter1 as IBaseFilter, nil, VideoWindow1 as IBaseFilter); end; FilterGraph1.Play; end; Again, that should all be familiar to you from my other tutorial. OK, so we're now in a position to add the AsfWriter filter and code for the basic ASF network and file writer.
|