Upload
ann-neal
View
213
Download
0
Embed Size (px)
Citation preview
DirectShow
Introduction to DirectShow
• playback or capture video and audio streams
• Support format• Advanced System Format (ASF)• Motion Picture Experts Group (MPEG)• Audio-Video Interleaved (AVI)• MPEG Audio Layer-3 (MP3)• WAV sound files
Introduction to DirectShow
• automatically detects video and audio acceleration hardware
• Simplifies• Media playback, format conversion, capture
task• Provides access to the underlying stream
control architecture• you can create your own component to
support new format
Introduction to DirectShow
• Applications you can write• DVD player, video editing APs, • AVI to ASF converter, MP3 players• Digital video capture
• Techniques• Component Object Model (COM)• If you want to extend DirectShow, you need und
erstand COM
Supports Formats in DirectShowFile Types
Windows Media Audio (WMA) Windows Media® Video (WMV)*
Advanced Systems Format (ASF)*
MPEG
AVI QuickTime (version 2 and lower)
WAV AIFF
AU SND
MIDI
* Need Windows Media® Format SDK
Supports Formats in DirectShow
Compression formats
ISO MPEG-4 video version 1.0* WMA*, WMV*, MP3
Microsoft MPEG-4 version 3* Sipro Labs ACELP*
Digital Video (DV) MPEG-1 (decompression only)
MJPEG Cinepak
MPEG2 decoder is not support by DirectShow
DirectShow 與其他 DirectX 元件的關係
DirectShow FAQ
• What OS does DirectShow support?• Win98, Win2000, WinME, WinXP
• Do I need to know COM knowledge?• How to instantiate them• Access the interface they expose• Manage reference count
• (Filter designer requires more )
• Is there a DirectShow Hardware Compatibility List (HCL) ? • Using DirectDraw & DirectSound hardware, if they available• Or using GDI video & waveOut* audio
DirectShow FAQ
• What language can I use ?• DirectShow is designed for C++• VB access subset of the API• Script based DVD or TV AP
• Will it accessible through managed code? • no current plans, the CLR is not recommended for
performance reasons
• How does DirectShow relate to Microsoft® ActiveMovie®? • the original name for DirectShow
DirectShow FAQ
• Information• MSDN DirectX Developer Center
• http://go.microsoft.com/fwlink/?LinkId=10138• MSDN Audio & Video node
• http://go.microsoft.com/fwlink/?LinkId=19380• Mail list
• http://discuss.microsoft.com/archives/DIRECTXAV.htm
• Use Net• microsoft.public.win32.programmer.directx.video
FAQ
• Books• Programming Microsoft® DirectShow
® for Digital Video and Television
• DirectShow: Core Media Technology in Windows XP Empowers You to Create Custom Audio/Video Processing Components
FAQ
• How do I build my application?
Header file Required For
Dshow.h All DirectShow APs
Header File
Library Files
Library file Description
Strmiids.lib Exports
• the Class ID (CLSIDs)
• Interface ID (IIDs)
Quartz.lib Exports the AMGetErrorText function, 若沒用 ,可以不 link
FAQ
• Detect whether DirectShow is installed?
IGraphBuilder *pGraph; HRESULT hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **) &pGraph);
Introduction to DirectShow Application Programming
Filter & Filter Graphs
• Filter is a component and building block• receive input and produce output
FilterDecode MPEG-1
MPEG-1 encodedstream
Frame1
Frame2
Frame3
Filter Graph
• APs performs task by connecting chains of filters together
• A set of connected filters is called a filter graph
a filter graph for playing an AVI file
Writing a DirectShow Application
• Three tasks must be performed
建立 Filter Graph Manager利用 Filter Graph Manager建立 filter graph
利用 Filter Graph Manager控制 filter graph
1 2 3
When processing is completed, the application releases the Filter Graph Manager and all of the filters
IMediaControl *pControl; hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
IMediaEvent *pEvent; hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
Controller: starting and stopping the graph
Event Interface: getting event from the graph filter
Simple Model
hr = pGraph->RenderFile(L"C:\\Example.avi", NULL);
RenderFile create a graph filter that can play the specified file.
一定是 NULLL"mms://live.media.hinet.net/Radio_UFO-NEWS98?RADIOWEBB7CA5B35-4E8E-4E5B-9918-BF7F1ABDA555"
播放 news98 廣播電台串流
hr = pControl->Run();
Controller: run1. Data moves through the filters2. Rendered as video and audio3. Playback occurs on a
separate thread
Run()
延伸閱讀
• Using COM• 內容
• 想瞭解 COM 的基本原理• 如何建立 COM object• 如何使用 COM interface• 管理 COM 物件的 lifetime• 使用 C 存取 COM 物件• 使用 Macros 呼叫 DirectX COM Method
DirectX SDK