Click here to Skip to main content
12,451,896 members (63,471 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

47.3K views
29 bookmarked
Posted

DirectShow Filters (For Beginners)

, 23 Sep 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
DirectShow filters are described in an easy to understand way.

Introduction

DirectShow filters are COM components which are connected together to build a filter graph. A filter graph is a complete mechanism (different filters connected together) which is needed to run a media file. Normally, a filter is capable of doing a single work, meaning a filter is an entity which is fully capable of processing media file data. Therefore, if you want to process the media file data, the most powerful technique is to build your own filter which can perform the required job.

Modular Design

Another benefit of building your own filter is that, internally, DirectShow has a modular design, meaning it is made up of small components working together to do a job. This design frees the developer from many worries. If you build your own filter (according to specifications), you don't need to worry about the other parts of the filter graph. If your filter works OK, then every thing will be OK. Otherwise, you are confirmed that your own filter is malfunctioning and not any other filter, because the other filters are already tested by the respective developers.

Data Flow in the Filter Graph

Data flows in the filter graph from one filter to another. The filter which gives the data is called the upstream filter and the filter which takes that data is called a downstream filter. The data flows from upstream filter to downstream filter, and this is called upstream filter push data (see Transport for push and pull).

Filter Types

Normally, filters are divided in three categories:

  1. Source filters
  2. Transform filters
  3. Renderer filters

Let us see them briefly.

Source Filters

These are the source of data that flow inside the filter graph. They provide data to the downstream filters (or downstream filter snatches data from the source filter, see Transport below). They come in three categories: capture source filters, file source filters, creator source filters. Capture source filters are those that get data form capture devices, such as camcorders or web cams. File source filters are those that get data from stored files. And the last, creator source filters are the type of filters that create data themselves to be flown in the filter graph.

Transform Filters

This is the category of filters which is used and created most. Any filter other then the source filter and renderer filter (see below) is called a transform filter. They get data from a source filter or any other filter upstream, and do the custom operation over data and pushes that data downstream. The custom operation here means the work they are made for; some parse data, others decode data, or any operation you want to be done over data.

Renderer Filters

The data in the filter graph flows from the source filter through the transform filters towards the renderer filter. This is the filter which sits at the end of the filter graph. The examples are filters which show video over screen, or write data to a file.

Connecting Filters

A filter is a COM component which has input and output pins. These are also COM components. All data travels through these pins. The output pin of the upstream filter is connected to the input pin of the downstream filter.

Connection Requirements

It is not so easy to connect any two filter pins. There must be a negotiation of some requirements. The actual negotiation work is done by the pins, which must be met before a connection takes place.

What are these requirements and why must they be met. Let us see:

The requirements are:

  1. Media type(s)
  2. Transport
  3. Allocators

Let us briefly see what they are.

Media Types

When two pins connect, they must agree on the format of the data which will be passed so that when actual data flow begins, the downstream filter can understand the format of data that the upstream filter is giving it.

Transport

The two also must agree on the protocol or the mechanism which will be used to exchange data. The most common transport is local memory. There are two mechanisms for local memory transport: push and pull. In the push model, data flows from the upstream filter to the downstream filter. And, in the pull model, the downstream filter pulls the data from the upstream filter. The pull model is only used in file source filters the filter read data from the file(s). All others use the push model.

Allocators

Allocators are also COM components which are responsible for managing the buffers which are used for data exchange.

More Info

You can visit my site www.tanvon.com on ongoing work in DirectShow.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

tanvon malik
Pakistan Pakistan
tanvon malik ( real name Tanveer Ahmad )I am a CNC Programmer, cnc setter, cnc operator. want to know about me visit my websites.
CNC Programming
CNC Manuals
Auto Owners Repair & Service Manuals

I been in Switzerland MAG former +FMS+ for CNC training.


Most interesting technologies I like COM MFC DirectShow such as filter development. I am from Pakistan.
Have worked on projects mostly related video capturing, video data processing and real time object tracking on videos. For these I have worked on projects which use "Open CV Library". Which is mostly used for capturing data and its processing.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralMy vote of 4 Pin
Brendan Segraves24-Jan-13 5:14
memberBrendan Segraves24-Jan-13 5:14 
Questionselect output device with directshow Pin
kinani12-Aug-11 1:51
memberkinani12-Aug-11 1:51 
GeneralMy vote of 3 Pin
Mostafaz22-Nov-10 23:20
memberMostafaz22-Nov-10 23:20 
GeneralMy vote of 1 Pin
Balkrishna Talele8-Oct-09 23:29
memberBalkrishna Talele8-Oct-09 23:29 
GeneralLIVEVIDEO ROTATION OR FLIP H/V FILTER Pin
giuegiu6-Jul-09 21:12
membergiuegiu6-Jul-09 21:12 
GeneralRe: LIVEVIDEO ROTATION OR FLIP H/V FILTER Pin
Aric Green13-Feb-10 20:05
memberAric Green13-Feb-10 20:05 
GeneralPush audio / video file to Server that uses Windows Media Services(WMS) Pin
Harshil_Gunchala14-Feb-09 1:57
memberHarshil_Gunchala14-Feb-09 1:57 
GeneralFME Pin
Paul the Great18-Jan-09 1:28
memberPaul the Great18-Jan-09 1:28 
Generaldirect show Pin
Member 242714927-Dec-07 19:04
memberMember 242714927-Dec-07 19:04 
GeneralRe: direct show Pin
Aric Green13-Feb-10 20:09
memberAric Green13-Feb-10 20:09 
Questionhow to design parser filters. Pin
amiya das27-Sep-07 3:17
memberamiya das27-Sep-07 3:17 
Questionhoe to create a parser filter. Pin
amiya das27-Sep-07 0:17
memberamiya das27-Sep-07 0:17 
AnswerRe: hoe to create a parser filter. Pin
tanvon malik27-Sep-07 3:02
membertanvon malik27-Sep-07 3:02 
GeneralMy DirectShow sample filters ... Pin
Daniel Strigl24-Sep-07 3:55
memberDaniel Strigl24-Sep-07 3:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 24 Sep 2007
Article Copyright 2007 by tanvon malik
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid