?? 利用 directshow 開(kāi)發(fā)自己的 filter(6) - directshow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).htm
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0051)http://tech.ddvip.com/2006-04/11443572604083_6.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng)</TITLE><!-- 本模板由 legmail 最后于 2007-09-19 13:47 修改 -->
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).files/tech_content.css"
type=text/css rel=stylesheet>
<STYLE>.nav {
BACKGROUND: #f2f6fb; WORD-SPACING: 20px; TEXT-INDENT: 5px; LINE-HEIGHT: 28px; BORDER-BOTTOM: #aaa 1px solid; HEIGHT: 28px; TEXT-ALIGN: left
}
</STYLE>
<SCRIPT><!--document.domain = 'ddvip.com';var node = 'tech';var subid = "2006-04-07_4083";--></SCRIPT>
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV id=main><!-- 頁(yè)面頭部 -->
<DIV class=header>
<DIV class=top_nav><A href="http://www.ddvip.com/">豆豆首頁(yè)</A> - <A
href="http://down.ddvip.com/">軟件下載</A> - <A
href="http://code.ddvip.com/">源碼下載</A> - <A
href="http://down.ddvip.com/news">軟件資訊</A> - <A
href="http://book.ddvip.com/">小說(shuō)閱讀</A> - <A
href="http://club.ddvip.com/">技術(shù)論壇</A> - <A
href="http://man.ddvip.com/">技術(shù)手冊(cè)</A> - <A
href="http://www.ddvip.com/link">網(wǎng)址導(dǎo)航</A> - <A
href="http://law.ddvip.com/">法律資訊</A> - <A
href="http://blog.ddvip.com/">博客人生</A> </DIV>
<DIV class=sitelogo><IMG alt=網(wǎng)站LOGO
src="利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).files/logo.gif">
<DIV class=top_ad_580x60 id=top_ad_580x60></DIV></DIV>
<DIV class=clear></DIV>
<UL class=global_nav>
<LI><A href="http://tech.ddvip.com/index.html">技術(shù)首頁(yè)</A> </LI>
<LI><A href="http://tech.ddvip.com/os/index.html">操作系統(tǒng)</A> </LI>
<LI class=global_nav_c><A
href="http://tech.ddvip.com/program/index.html">程序設(shè)計(jì)</A> </LI>
<LI><A href="http://tech.ddvip.com/network/index.html">網(wǎng)絡(luò)技術(shù)</A> </LI>
<LI><A href="http://tech.ddvip.com/network/server/index.html">服務(wù)器</A> </LI>
<LI><A href="http://tech.ddvip.com/safe/index.html">安全技術(shù)</A> </LI>
<LI><A href="http://tech.ddvip.com/web/index.html">Web開(kāi)發(fā)</A> </LI>
<LI><A href="http://tech.ddvip.com/db/index.html">數(shù)據(jù)庫(kù)</A> </LI>
<LI><A href="http://tech.ddvip.com/pic/index.html">平面設(shè)計(jì)</A> </LI>
<LI><A href="http://tech.ddvip.com/mediamovice/index.html">三維動(dòng)畫(huà)</A> </LI>
<LI><A href="http://tech.ddvip.com/cert/index.html">認(rèn)證考試</A> </LI>
<LI><A href="http://tech.ddvip.com/soft/index.html">軟件應(yīng)用</A> </LI>
<LI><A href="http://tech.ddvip.com/machine/index.html">機(jī)械電子</A> </LI></UL>
<DIV class=nav><A
href="http://tech.ddvip.com/program/vc/visualstudio/index.html">VisualStudio</A>
<A href="http://tech.ddvip.com/program/vc/interface/index.html">界面</A> <A
href="http://tech.ddvip.com/program/vc/view/index.html">視圖</A> <A
href="http://tech.ddvip.com/program/vc/pic/index.html">圖像</A> <A
href="http://tech.ddvip.com/program/vc/multimedia/index.html">多媒體</A> <A
href="http://tech.ddvip.com/program/vc/database/index.html">數(shù)據(jù)庫(kù)</A> <A
href="http://tech.ddvip.com/program/vc/windows/index.html">Windows系統(tǒng)</A> <A
href="http://tech.ddvip.com/program/vc/file/index.html">文件</A> <A
href="http://tech.ddvip.com/program/vc/comnet/index.html">COM/.NET</A> <A
href="http://tech.ddvip.com/program/vc/network/index.html">網(wǎng)絡(luò)通信</A> <A
href="http://tech.ddvip.com/program/vc/integrated/index.html">綜合</A> <A
href="http://tech.ddvip.com/program/softjeer/index.html">軟件工程</A> </DIV></DIV>
<DIV class=tlad id=tech_content_tl></DIV><!-- 內(nèi)容部分 -->
<DIV class=content>
<DIV class=location><A href="http://www.ddvip.com/" target=_balnk>豆豆網(wǎng)</A> >
<A href="http://tech.ddvip.com/index.html">技術(shù)應(yīng)用</A> > <A
href="http://tech.ddvip.com/program/index.html">程序設(shè)計(jì)</A> > <A
href="http://tech.ddvip.com/program/vc/index.html">VC</A> > <A
href="http://tech.ddvip.com/program/vc/multimedia/index.html">VC多媒體編程</A> >
正文 </DIV>
<DIV class=content_left>
<DIV class=article>
<DIV class=article_title>
<H1>利用 DirectShow 開(kāi)發(fā)自己的 Filter</H1>
<DIV class=title_bottom>
<SCRIPT language=javascript
src="利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).files/title_bottom.js"></SCRIPT>
</DIV>
<P><A href="http://www.ddvip.com/">豆豆網(wǎng)</A> <A
href="http://tech.ddvip.com/">技術(shù)應(yīng)用頻道</A> 2006年07月23日
<A href="http://club.ddvip.com/">社區(qū)交流</A></P></DIV>
<DIV class=article_content>
<DIV class=title_bottom_cpr>
<SCRIPT
src="利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).files/ad_title_bottom.js"></SCRIPT>
</DIV><!--ID="929"-->
<DIV class=searchhot>關(guān)鍵字: <A href="http://tech.ddvip.com/search.php?key=漢諾塔"
target=_blank>漢諾塔</A> <A href="http://tech.ddvip.com/search.php?key=VC++編程"
target=_blank>VC++編程</A> <A href="http://tech.ddvip.com/search.php?key=應(yīng)用程序"
target=_blank>應(yīng)用程序</A> <A href="http://tech.ddvip.com/search.php?key=無(wú)閃爍刷屏"
target=_blank>無(wú)閃爍刷屏</A> <A href="http://tech.ddvip.com/search.php?key=DirectX"
target=_blank>DirectX</A> <A href="http://tech.ddvip.com/search.php?key=圖形特技"
target=_blank>圖形特技</A> </DIV>
<DIV class=article_z>
<H2>本文詳細(xì)介紹利用 DirectShow 開(kāi)發(fā)自己的 Filter </H2></DIV>
<DIV class=article_ad>
<SCRIPT language=javascript
src="利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).files/ads_250x250.js"></SCRIPT>
</DIV>
<DIV class=article_c id=fontsize>
<P> 下面筆者就從本人的實(shí)際經(jīng)驗(yàn)出發(fā),對(duì)Filter基類的選擇提出幾點(diǎn)建議供大家參考。首先,你必須明確這個(gè)Filter要完成什么樣的功能,即要對(duì)Filter項(xiàng)目進(jìn)行需求分析。請(qǐng)盡量保持Filter實(shí)現(xiàn)的功能的單一性。如果必要的話,你可以將需求分解,由兩個(gè)(或者更多的)功能單一的Filter去實(shí)現(xiàn)總的功能需求。</P>
<P> 其次,你應(yīng)該明確這個(gè)Filter大致在整個(gè)Filter
Graph的位置,這個(gè)Filter的輸入是什么數(shù)據(jù),輸出是什么數(shù)據(jù),有幾個(gè)輸入Pin、幾個(gè)輸出Pin等等。你可以畫(huà)出這個(gè)Filter的草圖。弄清這一點(diǎn)十分重要,這將直接決定你使用哪種“模型”的Filter。比如,如果Filter僅有一個(gè)輸入Pin和一個(gè)輸出Pin,而且一進(jìn)一處的媒體類型相同,則一般采用CTransInPlaceFilter作為Filter的基類;如果媒體類型不一樣,則一般選擇CTransformFilter作為基類。</P>
<P> 再者,考慮一些數(shù)據(jù)傳輸、處理的特殊性要求。比如Filter的輸入和輸出的Sample并不是一一對(duì)應(yīng)的,這就一般要在輸入Pin上進(jìn)行數(shù)據(jù)的緩存,而在輸出Pin上使用專門的線程進(jìn)行數(shù)據(jù)處理。這種情況下,F(xiàn)ilter的基類選擇CSource為宜(雖然這個(gè)Filter并不是源Filter)。當(dāng)Filter的基類選定了之后,Pin的基類也就相應(yīng)選定了。接下去,就是Filter和Pin上的代碼實(shí)現(xiàn)了。有一點(diǎn)需要注意的是,從軟件設(shè)計(jì)的角度上來(lái)說(shuō),應(yīng)該將你的邏輯類代碼同F(xiàn)ilter的代碼分開(kāi)。下面,我們一起來(lái)看一下輸入Pin的實(shí)現(xiàn)。你需要實(shí)現(xiàn)基類所有的純虛函數(shù),比如CheckMediaType等。在CheckMediaType內(nèi),你可以對(duì)媒體類型進(jìn)行檢驗(yàn),看是否是你期望的那種。因?yàn)榇蟛糠諪ilter采用的是推模式傳輸數(shù)據(jù),所以在輸入Pin上一般都實(shí)現(xiàn)了Receive方法。有的基類里面已經(jīng)實(shí)現(xiàn)了Receive,而在Filter類上留一個(gè)純虛函數(shù)供用戶重載進(jìn)行數(shù)據(jù)處理。這種情況下一般是無(wú)需重載Receive方法的,除非基類的實(shí)現(xiàn)不符合你的實(shí)際要求。而如果你重載了Receive方法,一般會(huì)同時(shí)重載以下三個(gè)函數(shù)EndOfStream、BeginFlush和EndFlush。我們?cè)賮?lái)看一下輸出Pin的實(shí)現(xiàn)。一般情況下,你要實(shí)現(xiàn)基類所有的純虛函數(shù),除了CheckMediaType進(jìn)行媒體類型檢查外,一般還有DecideBufferSize以決定Sample使用內(nèi)存的大小,GetMediaType提供支持的媒體類型。</P></DIV><!-- 分頁(yè) -->
<DIV class=page><A
href="http://tech.ddvip.com/2006-04/11443572604083_5.html">上一頁(yè)</A><A
href="http://tech.ddvip.com/2006-04/11443572604083.html">1</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_2.html">2</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_3.html">3</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_4.html">4</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_5.html">5</A><SPAN
class=current>6</SPAN><A
href="http://tech.ddvip.com/2006-04/11443572604083_7.html">7</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_8.html">8</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_9.html">9</A><A
href="http://tech.ddvip.com/2006-04/11443572604083_7.html">下一頁(yè)</A></DIV><!-- 分頁(yè)end -->
<P
style="PADDING-RIGHT: 4px; FONT-SIZE: 12px; COLOR: #000000; TEXT-ALIGN: right">作者:智慧的魚(yú)
責(zé)編:豆豆技術(shù)應(yīng)用</P>
<DIV id=art_content_end_468x60>
<SCRIPT
src="利用 DirectShow 開(kāi)發(fā)自己的 Filter(6) - DirectShow - 技術(shù)應(yīng)用 - 豆豆網(wǎng).files/ads_468x60.js"></SCRIPT>
</DIV>
<DIV class=realated_search>點(diǎn)擊搜索更多"<A
href="http://tech.ddvip.com/search.php?key=DirectShow"
target=_blank>DirectShow</A>"相關(guān)信息</DIV></DIV>
<DIV class=related>
<DIV class=relatedtop>與“利用 DirectShow 開(kāi)發(fā)自己的 Filter”相關(guān)的文章</DIV>
<UL>
<LI><A
href="http://tech.ddvip.com/2007-03/117395236821211.html">VC+DirectShow對(duì)視頻進(jìn)行圖片處理之二</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117395231221210.html">VC+DirectShow對(duì)視頻進(jìn)行圖片處理之三</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117390782121190.html">VC+DirectShow對(duì)視頻進(jìn)行圖片處理之四</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117390773621189.html">VC+DirectShow對(duì)視頻進(jìn)行圖片處理之五</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117390736921184.html">VC+DirectShow對(duì)視頻進(jìn)行圖片處理之六</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2006-04/11443595404132.html">基于DirectShow非線性編輯DES</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2006-04/11443554004063.html">用DirectShow抓取影片幀</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2006-04/11443526404035.html">使用DirectShow驅(qū)動(dòng)攝像頭</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2006-04/11443525804034.html">在VC中調(diào)用DirectShow全屏播放視頻</A>
</LI></UL></DIV>
<DIV class=clear></DIV>
<DIV class=related>
<DIV class=relatedtop>本欄目更新</DIV>
<UL>
<LI><A href="http://tech.ddvip.com/2007-09/118923357233810.html">漢諾塔游戲的設(shè)計(jì)</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117475629722007.html">也玩視覺(jué)效果:VC++編程實(shí)現(xiàn)仿真火焰</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117449675921901.html">將視頻演示作為應(yīng)用程序的啟動(dòng)封面</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117449579821897.html">VC無(wú)閃爍刷屏技術(shù)的實(shí)現(xiàn)</A>
</LI>
<LI><A
href="http://tech.ddvip.com/2007-03/117445483921891.html">創(chuàng)建DirectX環(huán)境</A>
</LI>
<LI><A href="http://tech.ddvip.com/2007-03/117445468521890.html">Visual
C++中的圖形特技</A> </LI>
<LI><A href="http://tech.ddvip.com/2007-03/117412982221532.html">Web
版本檢查以及為應(yīng)用程序添加聲音效果</A> </LI>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -