Download presentation
Presentation is loading. Please wait.
1
DirectShow - a technical introduction
Qiming Lu / ATG - Video Nov/22/2006 (It takes 2 hrs…)
2
Who Am I? 陆其明 / Qiming Lu Graduated from Nanjing University in 2000, majoring in E.E. Over 7 years of VC++ experience and over 6 years of multimedia experience Awarded as a Microsoft Most Valuable Professional (MVP) for 3 times since 2004 My profile on Microsoft website: 4 books have been published: DirectShow Developing Tutorial (Tsinghua University Press, 2003), DirectShow Applications (Science Press, 2004), Windows Media Programming Guide (Tsinghua University Press, 2005), A Practical Guide to Script-Driven Software Development (Tsinghua University Press, 2006) 《DirectShow开发指南》《DirectShow实务精选》《Windows Media编程导向》《脚本驱动的应用软件开发方法与实践》 Joined Sonic on Apr/1, Working on HD DVD Player now…
3
Agenda Overview of DirectShow Basic Concepts of DirectShow Tips on DirectShow Development Tips on Learning DirectShow New Updates of DirectShow Demo & Homework Q&A
4
Overview of DirectShow
DirectShow is a set of APIs to enable multimedia application development DirectShow is a COM-based SDK DirectShow is only available on Windows (including Windows CE) DirectShow was a member of DirectX DirectX = DirectSound + DirectDraw + Direct3D + DirectShow + DirectInput + DirectPlay + … What can we do using DirectShow? Audio / Video capture Watch / Record TV on PC Media file playback Streaming media playback DVD playback Video editing / transcoding
5
Overview of DirectShow
System Architecture
6
Basic Concepts of DirectShow
So many concepts (Filter / Pin / Filter Graph / Media Type / Intelligent Connect / Push / Pull / Sample / Quality Control / Media Seeking / DMO…) Let’s talk about… Filter (basic interface: IBaseFilter) is a kind of COM component is a basic / minimum functional unit must be added to a filter graph must be connected to other filter(s) has one or more pins has 3 states: stopped, paused, running has 3 basic types: source, transform, renderer must be registered before being used in most cases Pin (basic interface: IPin) acts as a window of Filter has a direction: either Input or Output has one or more preferred media types connection: upstream filter’s output pin downstream filter’s input pin Filter Graph (manager interface: IFilterGraph, IGraphBuilder, IVideoWindow, IMediaSeeking…) is constructed with some specific purpose is a container / manager for filters looks like:
7
Basic Concepts of DirectShow
Media Type typedef struct _MediaType { GUID majortype; GUID subtype; BOOL bFixedSizeSamples; BOOL bTemporalCompression; ULONG lSampleSize; GUID formattype; IUnknown *pUnk; ULONG cbFormat; [size_is(cbFormat)] BYTE *pbFormat; } AM_MEDIA_TYPE; Major Type (MEDIATYPE_Video, MEDIATYPE_Audio, MEDIATYPE_Stream…) Sub Type (MEDIASUBTYPE_YUY2, MEDIATYPE_RGB32, MEDIATYPE_PCM…) Format Type (FORMAT_MPEGVideo, FORMAT_VideoInfo, FORMAT_WaveFormatEx…) Format Details (pbFormat): is a structure of MPEG1VIDEOINFO or VIDEOINFOHEADER or WAVEFORMATEX, and determined by Format Type Pin Connection / Intelligent Connect always from an output pin to an input pin is a process of media type negotiation between peer pins (please read the implementation codes of CBasePin::AgreeMediaType and CBasePin::TryMediaTypes) basically uses the API: IFilterGraph::ConnectDirect(IPin *ppinOut, IPin *ppinIn, const AM_MEDIA_TYPE *pmt) Intelligent Connect – easy to use, but please be aware and be careful!!! IGraphBuilder::AddSourceFilter, IGraphBuilder::RenderFile, IGraphBuilder::Render, IGraphBuilder::Connect
8
Basic Concepts of DirectShow
Data Flow & Sample Two modes: Push vs. Pull Sample is a wrapper for media data and meta data Basic interface: IMediaSample (GetPointer, SetTime, GetTime…) Virtual Source Filter
9
Basic Concepts of DirectShow
AV Sync / Timestamp / Quality Control AV Sync is basically achieved by timestamp and reference clock Timestamp is carried by media samples, including startTime & endTime IMediaSample::SetTime / GetTime measured by REFERENCE_TIME, uses 10-7 s as the unit Quality Control is a mechanism to improve total playback experience Media Seeking (basic interface: IMediaSeeking) is a way to play media content at a random position is a way to know the status of playback DirectX Media Objects is light-weighted component for multimedia data processing more flexible than filters, but NOT the replacement of filters Microsoft suggests re-writing some transform filters to DMOs, e.g. Codec
10
Tips on DirectShow Development
Be aware of what you really want to make… Tips on DShow Filter Development Refer to some SDK filter samples Choose a proper parent for your filter (CSource? CTransformFilter? CTransInPlaceFilter? CBaseVideoRenderer? CBaseFilter?) Separate the commercial logic from the filter framework Tips on DShow Application Development Refer to some SDK application samples Try to build your filter graph using Graphedt.exe first if possible Register your application-created filter graph to ROT for debugging purpose A DShow Filter? A DShow Application?
11
Tips on Learning DirectShow
If you’re writing a DShow application, get some general knowledge of COM If you’re writing a DShow filter, be sure to learn more details about COM If you want to be an expert, read all base classes delivered with DShow SDK SDK documentations and samples are always a good reference Reading sample codes is a good point to start, but practice is more important Be patient! You can’t do well in DirectShow in couples of days Understand DirectShow to understand the principles of multimedia processing Be ready to share your experience with others when you’re experienced
12
New Updates of DirectShow
DirectShow is NOT a member of DirectX any more The latest version of DirectX is 9.0, and the next version is 10.0 DirectX 10 only works with Windows Vista, and can’t be installed onto Windows XP Windows Vista initially integrates DirectX 9 DirectShow is good, but NOT good enough… Filter is heavy-weighted and complicated Filter can’t be used outside filter graph The topology of filter graph is static, and not easy to change The filter graph isn’t flexible enough to enable dynamic media type changing DirectShow doesn’t provide a protected environment for media content DirectShow doesn’t support playlist DirectShow Editing Services is not flexible, and not easy to extend Windows Media Foundation will be a replacement of DirectShow WMF begins to be available on Windows Vista WMF currently focuses on Content Protection Audio and Video Quality DRM Interoperability
13
New Updates of DirectShow
The Lifecycle of DirectShow & WMF
14
Demo & Homework Demo: How to Use Graphedt.exe Find a filter you want
Register / Unregister a filter Add filters to the filter graph and connect them one another Playback control: Run / Pause / Stop / Seek A useful tool: Filter Tracer Review application-created filter graph(s) Review Windows-Media-Player-created filter graph(s) Homework: Write a simple media player It’s a console application. Command line: myplayer c:\test.mpg As for code lines, the less, the better You can refer to SDK sample: PlayWnd
15
Q&A Thank You!
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.