Broadcast-driven system Series Lectures: 3

Source: Internet
Author: User

Three cores Application Design
Microsoft provides a lightweight ActiveX control in the XP operating system. The use of this control will make application development extremely convenient. This article will discuss the design of the DVB-S digital TV application program without this control Win2000 operating system. For such applications, you must manually connect the required filters to form a complete filter chart.

Before application development, ensure that the digital TV receiving card and its drivers are correctly installed and loaded successfully. In this case, the corresponding filters should be displayed under the Export source filters directory of graph edit and under the component er components directory respectively. Take the twinhandtv sat (shuanghan DVB-S) receiving card as an example, in these two directories, we can see that twinhan dvbs using tuner filter and twinhan dvbs using capture filter two device filters. For the receiving cards of some hardware providers, these two control nodes may be implemented by a filter in the receiver, so they only act as a filter in a directory.

The public details related to DirectShow application design are not discussed in the following sections, with emphasis on the section on digital TV application design. For simplicity, the following code does not include error handling.

1. Initialization
Like a normal DirectShow application, the program should first initialize the COM component and then create a filter chart object. The Code is as follows:
Ccomptr pgraph;
Coinitializeex (null, coinit_apartmentthreaded );
Pgraph. cocreateinstance (clsid_filtergraph );

2. Get the tuning request object
The previous unified tuning model has discussed in detail the tuning details. In an application, you can use system enumeration to obtain an existing tuning space, or create a new tuning space to generate a tuning request and submit it to the network provider filter. The following code takes the generation of a new tuning space as an example (the network type is DVB-S) to illustrate the generation of the tuning request object:
// Create dvbstuningspace object and set its properties
Ccomptr pidvbstuningspace = NULL;
Pidvbstuningspace. cocreateinstance (clsid_dvbstuningspace );
Pidvbstuningspace-> put_uniquename (bstrname); // set a unique name for this object
Pidvbstuningspace-> put_friendlyname (bstrfriname); // set friendly name
Pidvbstuningspace-> put _ networktype (clsid_dvbsnetworkprovider );

// Create dvbslocator object and set it as the default locator of the dvbstuningspace above
Ccomptr plocatorval = NULL;
Plocatorval. cocreateinstance (clsid_dvbslocator );
Plocatorval-> put_symbolrate (dwsymbolrate); // set symbol rate
Plocatorval-> put_carrierfrequency (dwcarrfreq); // set Carrier Frequency
Plocatorval-> put_signalpolarisation (polar); // set polarization
Pidvbstuningspace-> put_defaultlocator (plocatorval );

// The source code for adding the this tuningspace to systemtuningspaces is omitted
// Create tunerequest object and set its Locator
Ccomptr pitunerequest = NULL;
Pidvbstuningspace-> createtunerequest (& pitunerequest );
Ccomqiptr pidvbtunerequest (pitunerequest );
Pidvbtunerequest-> put_locator (plocatorval );

The above Code creates a tuning request object (pointer: pidvbtunerequest) to provide it to the network provider filter. The Code does not set the priority Selection Component list, so each output pin of the MPEG-2 demultiplexer filter will output the default basic stream.

3. Create a network provider
As mentioned above, the network provider filter controls the tuning process and works with the transport information filter to retrieve program information from the transmission stream. To select the network provider type, you should ask the tuning space to obtain the network type information and select the corresponding network provider.

The selection and creation process code is as follows:
Ccomptr pnetworkprovider; // network provider Filter
Guid clsidnetworktype; // guid of the network type.
// Find the network type.
Pidvbstuningspace-> get _ networktype (& clsidnetworktype );
If (clsid_networktype = guid_null)
{
// This tuning space is analog TV, auxin, or some other non-linear type.
}
Else
{
// Create the network provider filter for this network type.
Pnetworkprovider. cocreateinstance (clsidnetworktype );
// Add the network provider to the graph.
Pgraph-> addfilter (pnetworkprovider, l "network provider ");
}
In the above Code, the itunerequest: get_tuningspace method obtains the tuning space of a specific tuning request, and obtains the network type guid using the ituningspace: Get _ networktype method, this GUID is passed as a parameter to cocreateinstance to create the corresponding network provider filter.

After creating a network provider and adding it to the filter graph, ask for its ituner interface and send the tuning request to it. The Code is as follows:
// Query for ituner.
Ccomqiptr ptuner (pnetworkprovider );
If (ptuner)
{// Submit the tune request to the network provider.
Ptuner-> put_tunerequest (pidvbtunerequest );
}
The put_tunerequest method of the ituner interface sends the tuning request to the network provider.

4. Add and connect other Filters
After successfully configuring the network provider using the tuning request, you can add the remaining filters and connect them to the filter graph.

The filter directly connected to the network provider filter is located in the tuner filter in the kernel source filters (directory GUID is kscategory_bda_network_tuner) directory. Depending on the hardware implementation, the tuner filter is followed by the capture filter or demodulator filter (the directory GUID is kscategory_bda_receiver_component) located in the component directory ). To find the device filter corresponding to the receiving card, perform system enumeration in the corresponding directory and try to establish a connection until the connection is successful.
The system enumeration method is the same as that of the DirectShow application.

After the device filter of the consumer is connected, the connection is followed by the MPEG-2 demultiplexer filter, as described above, which outputs five pins by default, you can choose to use smart connection technology to render each pin to create the entire filter chart. In particular, IP data output from the fourth pin needs to be connected to the secondary IP sink filter through the MPE filter. Further development is required to exploit the data. The complete filter Chart 3 is shown.

[Img] http://www.cctvpro.com.cn/jxlt/20010817/200108172911.gif#/img]

5. Application Control and Program Selection

Like a normal DirectShow application, Apis such as imediacontrol and imediaevent should be obtained from graphbuilder to control the operation of the filter chart, pause and stop, and capture and process events of interest to some applications.

After the filter graph is successfully created and runs, you can obtain Program-related information. The Pat table should be obtained first. The code for obtaining the Pat table is as follows:

// Get the next section with PID 0, which is reserved for the pat.
PID pid = 0x00; tid = 0x00;
DWORD dwtimeout = 500; // msec
Mpeg2_filter mpeg2_filter = {0 };
// The impeg2data interface is exposed by the MPEG-2 sections and tables Filter
Ccomptr psectionlist = NULL;
Pimpeg2data-> getsection (PID, tid, null, dwtimeout, & psectionlist );

You can use the psectionlist interface pointer to operate pat to obtain the program numbers available after this tuning and their corresponding PID. Applications can choose to broadcast one program. After the program is selected, You need to further obtain the PMT table of the program to obtain the ID of its basic stream component (audio, video, or data sub-stream, and map these basic stream IDs to the corresponding output pin of the demultiplexer filter to broadcast the program. The PMT table acquisition method is similar to pat, except that the PID in the getsection method should be the ID of the selected program, and the TID is 2.

When the application runs normally, you can still submit a new tuning request to the network provider filter to initiate a new tuning process. You can also switch to another program channel at any time; or set the components (audio, video, or data sub-streams) in a program channel to be available or unavailable.

Conclusion 4
This article discusses in detail the broadcast-driven system of Microsoft's digital TV technology and Microsoft's unified tuning model, and on this basis, implements a complete digital TV application. Based on a specific digital TV receiver card, this application can be further improved to achieve digital TV watching on a PC and receive audio in the DirectShow framework, video and IP packets are further processed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.