DirectShow technology description and application

zhaozj2021-02-16  51

DirectShow technology description and application

--- Release snow

DirectShow is my earliest touch with Microsoft technology, which is early than COM technology, I really don't know how I learned at the time. DirectShow is a multimedia control component based on COM component technology. It can perform media capture, format conversion, and playback. In fact, MediaPlayer is built on the DirectShow. The function can be said to be very powerful. This time I translated the instructions section of DirectShow in DirectX 8.1 and shared with you. For personal English level, there must be translated and missed, please don't finish correct, thank you for this. Blue_atlantis400@hotmail.com

DirectShow System Overview

Multimedia faces challenges:

Today's technologies mainly faced with the following points:

1. Multimedia data flow typically contains large data information, how to better deal with this data.

2. Since audio and video must be played synchronously, then you need to solve how they start and stop at the same time, and have the same playback rate (Rate).

3. Data streams can come from many places, such as local files, networks, telephone broadcasting, and digital cameras. How to solve them, make it possible to play and process the same.

4. Data streams can be different formats, such as AVI, and ASF can also be MPEG, etc. How to solve them, make it possible to play and process the same.

5. When implementing the design, do not understand the user's hardware configuration and performance. How to make the application have a machine-independent.

DirectShow solution

The original intention of DirectShow design is to solve all the technical problems involved in the above. Its main design is to simplify design tasks based on digital media applications based on Windows® platform. And make it no need to involve data transmission, hardware versatility, media synchronization, and more complex issues.

DirectShow applies DirectDraw® and DirectSound® technology to complete the processing of audio and video streams required. These technologies can efficiently put data image and audio restore (render) to the user's graphics card and sound card. DirectShow implements media synchronous playback by compressing the time-stamped in the media stream. In order to handle different possible data sources, data formats, and hardware systems, DirectShow uses a standardized structural system. In this, the application can mix and match differently referred to as filters (Filter, also known as filters, I remember to see the components in Photoshop.).

DirectShow provides a filter that captures and configures Windows Driver Model. Likewise, the filter also supports video capture cards and codecs via ACM and VCM interfaces.

In the DirectShow standard structure system, DirectShow Filters and Control (Control), diverse devices, local file systems, TV FM and video capture cards, VFW encoders, video display cards (via DirectDRAW or GDI, GDI ) and graphics Interaction (Communicate, Communication). Thus, DirectSHOW can isolate the application with the previously listed complexity. DirectShow also provides local compression and decompression filters for several file formats.

Filter table (Filters graph) and its components

filter

The filter is the most basic component of DirectShow. An application can connect different filters to a special requirement media functionality.

such as:

The Async File Source can read local files.

The TV Tuner filter can change the TV channel on the TV card.

MPEG-2 Splitter filters Decompose out video data from MPEG-2 data streams.

Although each filter has its own special features, but applications can access them with the same syntax, all filters support IBasefilter interface. Most filters can be used by the following categories:

The source filter provides raw data (RAW DATA, source data when processing). It can get data from local files, DVD discs, phone cards, capture cards, digital, or other data sources.

Transform filter accepts data from other filters to process it and passes it to the next filter (third-party filter, A Third filter). Conversion filters generally have these types: analysis, unprocessed byte streams and converted into meaningful media data; coding and decoding, conversion between compressed data and decompression data; splitters To divide a data stream into two or more data streams; mix, combine several data streams into a data stream.

Renderer filter data from other filters and play it, or passes to other hardware devices. Such filters include filters responsible for storing data on the reservoir. Video restore uses DirectDraw to display images, the default audio restore uses DirectSound to play audio.

DirectShow's playback, transformation, captures a filter in a variety of different media formats, which can work on any kind of Windows. Developers can also write custom filters to complete their needs.

Filter table and filter table manager

In order to complete a variety of tasks in DirectShow, the application should create one or more filters and connect them together. So the data is passed from one filter to the next, from the source filter one to the reduced filter. A set of filters working together are called filter tables.

Filter table, I think it is easier to understand the connection logic to a set of filters.

The filter table itself is not a real (Distinct) software component. However, it can be managed by a COM component called the Filter Table Manager. In some tasks, the filter table manager controls the status change of the filter table, establishes a reference clock for all filters, communicating for filters and applications. Filter Table Manager automatically creates a suitable filter table for file playback, or a part of the table can also establish a table of the table to reduce the work burden of the application.

Note Filters always reside in the same process as the Filter Graph Manager. They are always loaded from in-process servers. Therefore, method calls are not marshalled between filters, or between filters and the Filter Graph Manager.

In terms of terminology, the filter table is a straight line, non-cyclic, non-Connected table:

Straight: Data must be moved in the filter in advance.

Non-cyclone: ​​There is no filter in the filter table to be connected to a ring.

Non-connection: The filter table is a chain of the filter string instead of connection. That is to say, the filter cannot know what the filter is connected. Each filter is enclosed.

Pins (Pins)

Connect a filter to other filters called a needle. Each needle is a COM component object that supports an IPIN interface. Although the needle counts counts, the filter is the survival cycle of the filter's own pin control. The filter can be automatically established or destroyed in real time (runtime).

Each needle has only one transfer direction, namely input or output. It must be connected to the needles in the opposite direction. (I.e., only the needle can be used to connect to the input needle). Media data passes through the needle connection, always from the output pin to the input needle. Our direction of the input needle is called downstream, and the direction of the output needle is called upstream. (Some control information can be moved in the upstream direction)

When two needles are connected, the details of the connection must be provided, such as media types, subleed, and transport mechanisms (called transmitters). If there is any needle to refuse to connect, then the two filters cannot exchange data. Media Sample (Sample) and Media Types

When two filter is connected, they must use the same data type. Then, the upstream filter uses the data of the additional data type through the filter output pin, and the input needle of the downstream filter accepts data and enter the process. In this way, make sure the downstream filter can handle the data it accepts. In DirectShow, the data type is described using the AM_MEDIA_TYPE structure, referred to as a media type. The connection of each needle must determine a media type. Some needles can accept media types of parallel (a Wide Range), and other limited number of times.

Once the connection of the filter is established, the upstream filter can transmit the data to the downstream filter through the connection of the needle, and the upstream filter is packaged into a COM object called a media sample. Media samples support iMediaSample or iMediasample2 interface. Media samples that can be added to the actual media data include a time identifier to illustrate the current time of the sample.

More typical, one video media sample contains an image frame, and an audio media sample can contain several audio samples.

The filter automatically assigns memory to establish a media sample containing media data.

clock

It is very important to maintain a correct play rate when playing the media. For this goal, each media sample carries a time identifier to illustrate the time of the media data. Filter Table Manager maintains one time in the entire table. This clock is called a reference clock, and the time it provides is referred to as a reference time. The reference time is in a million second (100 nanaoseconds. I am counting right)

In some filter tables, the filter can provide a reference clock. For example, an audio reduction filter can typically be used for an accurate clock based on a sound card. If there is no filter to provide a clock, the filter table uses the Windows system clock.

(to be continued...)

转载请注明原文地址:https://www.9cbs.com/read-24712.html

New Post(0)