Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

282 lines
14 KiB

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="BDACap_files/filelist.xml">
<title>BDACap: AVStream Simulated Hardware Sample Driver</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>TC Pritchett</o:Author>
<o:LastAuthor>Anand Ganesh</o:LastAuthor>
<o:Revision>9</o:Revision>
<o:TotalTime>26</o:TotalTime>
<o:Created>2001-10-19T18:21:00Z</o:Created>
<o:LastSaved>2002-05-06T23:15:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>822</o:Words>
<o:Characters>4686</o:Characters>
<o:Company>Microsoft Corporation</o:Company>
<o:Lines>39</o:Lines>
<o:Paragraphs>10</o:Paragraphs>
<o:CharactersWithSpaces>5498</o:CharactersWithSpaces>
<o:Version>10.3501</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:GrammarState>Clean</w:GrammarState>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"MS Sans Serif";
panose-1:0 0 0 0 0 0 0 0 0 0;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:3 0 0 0 1 0;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:536871559 0 0 0 415 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:blue;
text-decoration:underline;
text-underline:single;}
p
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
pre
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"Times New Roman";}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=EN-US link=blue vlink=blue style='tab-interval:.5in'>
<div class=Section1>
<h2><span style='font-family:Verdana'>BDACap: AVStream Simulated Hardware
Sample Driver <o:p></o:p></span></h2>
<p><span style='font-size:10.0pt;font-family:Arial;color:red'>[This is
preliminary documentation and subject to change.]</span><span style='font-size:
10.0pt;font-family:Verdana'><o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>The BDACap sample is
based on the AVSHwS sample provided in the AVStream samples directory.
Modifications were made to allow the original AVSHwS sample to work the the
BDATuner sample.<span style='mso-spacerun:yes'>  </span>The purpose of the
sample is to demonstrate how to write a pin-centric AVStream minidriver. The
sample also shows how to implement DMA by using the related functionality
provided by AVStream.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>The driver is designed to
be used with the BDA sample software tuner driver (BDATuner.sys).<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>BUILDING THE SAMPLE<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>Build the sample by
typing <b>build -<span class=GramE>cz</span></b> in either the standard checked
or free build environment. A successful build produces BDACap<i>.sys.<o:p></o:p></i></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>To use the driver you
should build both BDACap.sys and BDATuner.sys.<span style='mso-spacerun:yes'> 
</span>Copy these files along with the BDA sample tuner INF (BDATuner.inf), the
BDA sample capture INF (BDACap.inf), and the software receiver INF
(BDASWRcv.inf) to an installation directory on the target machine.<span
style='mso-spacerun:yes'>  </span>To start installation of the drivers, right
click on <i>BDASWRcv.inf</i> and select Install.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>The sample works on x86
platforms and builds correctly using Microsoft® Visual C® 6.0. The driver uses
Plug and Play. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>This sample runs on
Microsoft® Windows® 2000 and Windows XP®. <o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>PROGRAMMING TOUR<o:p></o:p></span></h3>
<p><b><span style='font-size:10.0pt;font-family:Verdana'>DriverEntry</span></b><span
style='font-size:10.0pt;font-family:Verdana'> in <i>device.cpp</i> is the
initial point of entry. This routine passes control to AVStream through a call
to <b>KsInitializeDriver</b>. In this call, the minidriver passes the device
descriptor, an AVStream structure that recursively defines the AVStream object
hierarchy for a driver. This is common behavior for an AVStream minidriver. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>At device start time (see
the <b>CcaptureDevice::PnpStart</b> method in <i>device.cpp</i>), a simulated
piece of capture hardware is created (the ChardwareSimulation class)<span
class=GramE>,</span> a DMA adapter is acquired from the operating system and is
registered with AVStream through a call to <b>KsDeviceRegisterAdapterObject</b>.
This call is required for a sample that performs DMA directly into the capture
buffers, instead of using DMA to write to a common buffer. <o:p></o:p></span></p>
<p><i><span style='font-size:10.0pt;font-family:Verdana'>Filter.cpp</span></i><span
style='font-size:10.0pt;font-family:Verdana'> is where the sample lays out the
KSPIN_DESCRIPTOR_EX structure for the single capture pin. In addition, a
KSFILTER_DISPATCH structure and a KSFILTER_DESCRIPTOR structure are provided in
this source file. The filter dispatch provides only a create dispatch, a
routine that is included in <i>Filter.cpp</i>. The process dispatch is provided
on the pin, since this is a pin-centric sample. <o:p></o:p></span></p>
<p><i><span style='font-size:10.0pt;font-family:Verdana'>Capture.cpp</span></i><span
style='font-size:10.0pt;font-family:Verdana'> contains source for the transport
input and output pins on the capture filter. This is where the KSPIN_DISPATCH
structure for the unique pin is provided. This dispatch structure specifies a
Process callback routine, also defined in this source file. This routine is
where stream pointer manipulation and cloning occurs. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>The process callback is
one of two routines of interest in <i>Capture.cpp</i> that demonstrate how to do
DMA transfers using AVStream functionality. The other is <b>CCapturePin::CompleteMappings</b>.
These two methods show how to use the queue, obtain clone pointers, use
scatter/gather lists, and perform other DMA-related tasks. <o:p></o:p></span></p>
<p><i><span style='font-size:10.0pt;font-family:Verdana'>Hwsim.cpp</span></i><span
style='font-size:10.0pt;font-family:Verdana'> contains the hardware simulation
code and also code that fills the scatter/gather mappings. This source file
includes the Start, Pause and Stop methods for the hardware simulation class
(CHardwaresimulation). Transport synthesis code is also here. The supplied
objects provide a framework for synthesizing transport data. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>See comments in all .cpp
files. Also see complete AVStream documentation in the DDK documentation. <o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>RUNNING THE SAMPLE<o:p></o:p></span></h3>
<p><span class=GramE><span style='font-size:10.0pt;font-family:Verdana'>Once
installation is complete, access the driver through the graphedt tool.</span></span><span
style='font-size:10.0pt;font-family:Verdana'> <i>Graphedt.exe</i> is available
in the <i>Tools</i> directory of the DDK. In the Graphedt application, click
the Graph menu and select Insert Filters. Click Insert Filter and the sample <span
class=GramE>appears</span> under “Bda Receiver Component” as a single filter
labelled as “Sample BDA Capture”. Then insert a Network Provider (ATSC<span
class=GramE>) ,</span> connect it the the “Sample BDA Tuner”, and attach the
output of the Sample BDA Tuner filter to the input of the Sample BDA Capture
Filter. The Sample BDA Tuner Filter appears under the category “BDA Source
Filters”. Finally attach the output of the capture filter to the input pin of
the MPEG-2 Demultiplexer filter.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>The sample BDA capture
appears under &quot;BDA Receiver Components&quot; as &quot;Sample BDA
Capture&quot;.<span style='mso-spacerun:yes'>  </span>The sample BDA tuner
appears under “BDA Source Filters” as “Sample BDA Tuner Filter”.<span
style='mso-spacerun:yes'>  </span>The MPEG-2 demultiplexer appears under
“DirectShow Filters” as “MPEG-2 Demultiplexer”.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>COMMENTS<o:p></o:p></span></h3>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:Verdana'>For more
information on AVStream, see the DDK documentation. <o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
<h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
<pre><u>File</u><span style='mso-spacerun:yes'>           </span><u>Description<o:p></o:p></u></pre><pre><o:p>&nbsp;</o:p></pre><pre>BDACap.htm<span
style='mso-tab-count:1'>     </span>The Sample Tour documentation for this sample (this file).</pre><pre><span
class=GramE>Sources<span style='mso-tab-count:2'>        </span>The generic file for building the code sample.</span></pre><pre>BDACap.inf<span
style='mso-tab-count:1'>     </span>A sample capture installation file.</pre><pre><span
class=GramE>BDASWRcv.inf<span style='mso-tab-count:1'>   </span>A special “software receiver” installation file.</span></pre><pre>BDACap.h<span
style='mso-tab-count:1'>       </span>The main <span class=GramE>header file</span> for the sample.</pre><pre><span
class=GramE>device.cpp</span><span style='mso-tab-count:1'>     </span>DriverEntry, Plug and Play handling, initialization, device level code.</pre><pre><span
class=GramE>device.h</span><span style='mso-tab-count:1'>       </span>Header file for above.</pre><pre><span
class=GramE>filter.cpp</span><span style='mso-tab-count:1'>     </span>Filter level code for the capture filter.</pre><pre><span
class=GramE>filter.h</span><span style='mso-tab-count:1'>       </span>Header file for above.</pre><pre><span
class=GramE>capture.cpp</span><span style='mso-tab-count:1'>    </span>Pin level code for the capture pin, DMA handling.</pre><pre><span
class=GramE>capture.h</span><span style='mso-tab-count:1'>      </span>Header file for above.</pre><pre><span
class=GramE>hwsim.cpp</span><span style='mso-tab-count:1'>      </span>Hardware simulation code, filling scatter/gather mappings, etc.</pre><pre><span
class=GramE>hwsim.h</span><span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'>     </span><span
style='mso-tab-count:1'>   </span>Header file for above.</pre><pre>TStream.cpp<span
style='mso-tab-count:1'>    </span>Transport stream simulation framework.</pre><pre>TStream.h<span
style='mso-tab-count:1'>      </span>Header <span class=GramE>file</span> for above.</pre><pre>BDACap.rc<span
style='mso-tab-count:1'>      </span>Resource <span class=GramE>file</span> mainly for version.</pre><pre><o:p>&nbsp;</o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre><o:p>&nbsp;</o:p></pre>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=624
style='width:6.5in;mso-cellspacing:0in;mso-padding-alt:0in 5.4pt 0in 5.4pt'>
<tr style='mso-yfti-irow:0;mso-yfti-lastrow:yes;height:1.5pt'>
<td style='background:aqua;padding:.75pt .75pt .75pt .75pt;height:1.5pt'>
<p class=MsoNormal><span style='font-size:2.0pt;mso-bidi-font-size:12.0pt'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
</table>
<pre><o:p>&nbsp;</o:p></pre><pre><o:p>&nbsp;</o:p></pre>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:7.5pt;font-family:"MS Sans Serif";mso-bidi-font-family:"Courier New"'>©
2001 Microsoft Corporation</span><span style='font-size:10.0pt;font-family:
Verdana;mso-bidi-font-family:"Courier New"'> <o:p></o:p></span></p>
<pre><o:p>&nbsp;</o:p></pre></div>
</body>
</html>