directshow 9 程式設計

2021-04-13 12:28:26 字數 3316 閱讀 8457

定義

cb_videocapfilters: tcombobox;

cb_audiocapfilters: tcombobox;

cb_videoformats: tcombobox;

cb_audioformats: tcombobox;

cb_inputlines: tcombobox;

audiosourcefilter: tfilter;

videosourcefilter: tfilter;

filtergraph: tfiltergraph;   

videosysdev: tsysdevenum;

audiosysdev: tsysdevenum;

videomediatypes: tenummediatype;

audiomediatypes: tenummediatype;

列舉埠

vari: integer;

begin

videosysdev := tsysdevenum.create(clsid_videoinputdevicecategory);

for i := 0 to videosysdev.countfilters - 1 do

cb_videocapfilters.items.add(videosysdev.filters[i].friendlyname);

cb_videocapfilters.itemindex := 0;

audiosysdev := tsysdevenum.create(clsid_audioinputdevicecategory);

for i := 0 to audiosysdev.countfilters - 1 do

cb_audiocapfilters.items.add(audiosysdev.filters[i].friendlyname);

cb_audiocapfilters.itemindex := 0;

videomediatypes := tenummediatype.create;

audiomediatypes := tenummediatype.create;

end;

vari: integer;

begin

videosysdev := tsysdevenum.create(clsid_videoinputdevicecategory);

for i := 0 to videosysdev.countfilters - 1 do

cb_videocapfilters.items.add(videosysdev.filters[i].friendlyname);

cb_videocapfilters.itemindex := 0;

audiosysdev := tsysdevenum.create(clsid_audioinputdevicecategory);

for i := 0 to audiosysdev.countfilters - 1 do

cb_audiocapfilters.items.add(audiosysdev.filters[i].friendlyname);

cb_audiocapfilters.itemindex := 0;

videomediatypes := tenummediatype.create;

audiomediatypes := tenummediatype.create;

end;

選擇音訊源

varpinlist: tpinlist;

i, lineindex: integer;

abool: longbool;

begin

audiosysdev.selectguidcategory(clsid_audioinputdevicecategory);

if cb_audiocapfilters.itemindex <> -1 then

begin

audiosourcefilter.basefilter.moniker := audiosysdev.getmoniker(cb_audiocapfilters.itemindex);

audiosourcefilter.filtergraph := filtergraph;

filtergraph.active := true;

pinlist := tpinlist.create(audiosourcefilter as ibasefilter);

cb_audioformats.clear;

i := 0;

while i < pinlist.count do

if pinlist.pininfo[i].dir = pindir_output then

begin

audiomediatypes.assign(pinlist.items[i]);

pinlist.delete(i);

end else inc(i);

for i := 0 to audiomediatypes.count - 1 do

begin

cb_audioformats.items.add(audiomediatypes.mediadescription[i]);

end;

cb_audioformats.itemindex := 0;

filtergraph.active := false;

cb_inputlines.clear;

lineindex := -1;

for i := 0 to pinlist.count - 1 do

begin

cb_inputlines.items.add(pinlist.pininfo[i].achname);

with (pinlist.items[i] as iamaudioinputmixer) do get_enable(abool);

if abool then lineindex := i;

end;

cb_inputlines.itemindex := lineindex;

pinlist.free;

end;

end;

顯示屬性

showfilterpropertypage(self.handle, videosourcefilter as ibasefilter);

showfilterpropertypage(self.handle, audiosourcefilter as ibasefilter);

DirectShow程式設計之Filter原理

在directshow系統概述中介紹了directshow的總體系統框架。本文我們從程式設計師的角度,進一步深入 一下directshow的應用以及filter的開發。學習directshow filter的開發,不外乎以下幾種方法 看幫助文件 看示例 和看sdk基類源 看幫助文件,應著重於總體概念...

分享DirectShow程式設計的一點經驗

在 型別傳遞時,會有cmediatype的formattype成員,是乙個guid,其對應的結構型別我總結如下 format videoinfo videoinfoheader,videoinfo bigger than videoinfoheader,compatible with videoin...

網路程式設計9

1 伺服器模型 2 迴圈伺服器 初始化套接字以及其他準備工作,然後在準備接收客戶端連線的時候,使用while 1 來迴圈的檢測,是否有客戶端發起連線。如果有客戶端請求連線,那麼在伺服器端為其建立乙個執行緒,專門為這個客戶端服務。3 簡單的併發伺服器 在伺服器端,構建多個子程序或者子執行緒,當客戶端的...