This is a mirror of official site: http://jasper-net.blogspot.com/

DirectShow Filters Development Part 1: Video Rendering with Direct2D

| Tuesday, February 1, 2011
Introduction

This article is about DirectShow development in general and filters development in detail. I decided to share the knowledge and experience in this area so there will be a simple tutorial for developers who wish to write their own filters and can't find enough references on the web. I assume you have a basic knowledge of DirectShow graph management and C++/COM programming. All source code samples are using Visual Studio 2010 on Windows 7, and you have to install Windows SDK for Windows 7 and .NET Framework 4.

The strength of an API is measured not only by its capabilities but also by its extensibility model, and when talking about extensibility - DirectShow really shines: you can extend the framework by building its basic structure blocks called filters. Each filter is actually a C++ object with one or more nested objects called pins which are responsible for connections with other filters and data delivery between them.

Most of the time, you will be using existing filters as there are a plethora of them installed already on your OS, and you can download a lot of free filters from here. However, there are times when you need to do something unusual, and when working in a startup company with a low budget, it is not possible to buy what you need. So one day I found myself struggling with filters development...

DirectShow filters come in three flavors:

  1. Source filters – responsible for generating media samples and pushing them to downstream filters in the graph. Source filters themselves are divided into three groups:
  1. Filesource filters – filters which are responsible for parsing media files, reading media samples, and pushing them to appropriate output pins dealing with video, audio, text, or data.
  2. Capturesource filters – filters that are usually bound to some external device like webcam or video acquisition card, and responsible for generating media samples at a constant rate and pushing them to output pins.
  3. Livesource filters - filters that get video samples at an unspecified pace from the network stream or external function calls and push them downstream.
  • Transform filters – probably the vast majority of DirectShow filters which are responsible for en/decoding, de/multiplexing, parsing, and splitting media streams.  There are two kinds of transform filters:
    1. In place transformation – filters that perform some action on the media sample and deliver it to the output pin without any buffer copy.
    2. Transformation filters which receive a media sample, perform some action, and save its output in another media sample which is pushed down stream.
  • Renderer filters – filters that act as a "final station" for the media samples, and responsible for either sending the sample to the network, saving it to a file, or showing it on screen.  

  • Renderer filters

    Renderer filters are the most easy to implement, simply by inheriting the DirectShow base class and overriding some method calls, so I decided to start this series of articles with rendering filters.

    Filter development prerequisites

    After installing the Windows SDK, you have to build the baseclasses solution located in C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses in both Debug and Release configurations. After successful build, you will have the strmbasd.lib library in the Debug folder and strmbase.lib in the Release folder.

    Read more: Codeproject

    Posted via email from Jasper-net

    0 comments: