📄 dvdts.htm
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>DVDTS</TITLE>
</HEAD>
<BODY TEXT="#000000" LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff" leftmargin="8">
<FONT FACE="Verdana"><H2><A NAME="MYSAMPLE"></H2>
<H2>DVDTS: DVD Decoder Card Driver</A></H2>
<H3>SUMMARY</H3>
</FONT><FONT FACE="Verdana" SIZE=2><P>DVD is a trademarked name owned by the DVD Consortium.
DVD provides digital data storage that encompasses audio, video, and computer data.
Microsoft supports DVD in the following ways: </P>
<B><P>Support for DVD movie playback.</B> The DVD Consortium has defined two major
compression technologies to be used in storing video and audio on a DVD disc, MPEG2,
and AC-3. Support for these is the primary focus of this sample minidriver.</P>
<B><P>Support for DVD as a storage device.</B> Microsoft DVD-ROM read-only device support,
including support for the Universal Disc Format (UDF) version 1.01, is provided through
installable file system drivers. This aspect of DVD technology is completely independent
of movie playback, side-stepping copyright protection and other such issues.
Future DVD standards will allow for recordable devices, opening a wider range of options.
As indicated in the following diagram, the OEM minidriver documented in this article is used
only for AC-3 video and MPEG2 video support; UDF support is provided by Microsoft.</P>
<P>The diagram shows the complete support for existing DVD technologies under Microsoft®
Windows® and Windows NT®. The white boxes represent software supplied by Microsoft,
while the shaded components are provided by hardware vendors. The ovals represent hardware
supplied by independent hardware vendors (IHVs) and OEMs. On most PCs with Microsoft DVD
support, DVD works as a storage device and, if the proper decoding hardware is present,
supports full DVD-video playback.</P>
<P> </P>
</FONT><P><IMG SRC="dvdts.gif" WIDTH=567 HEIGHT=437></P>
<B><FONT FACE="Verdana" SIZE=2><P>Note:</B> Some components in this architecture will change
based on advances in other hardware technologies, such as the advent of accelerated graphics
port (AGP) or improvements in the PCI bus. The only components that will always be present
are the DVD-ROM driver, the UDF file system, and the DVD Splitter/Navigator.</P>
<P>The sample this article explores, <B>DvdTs.sys</B>, is an example of a real OEM minidriver
(as indicated in the gray Minidriver box in the above diagram) for a Toshiba® DVD decoder
card. The sample includes an .inf file that installs <B>DvdTs.sys</B> to replace
the core <B>TosDvd.sys</B> files in Windows 98 and Windows 2000 (<B>DvdTs.sys</B>
is functionally equivalent to <B>TosDvd.sys</B>). At the time of this writing,
some DVD movie
copy protection support was not yet fully implemented in Windows 2000.</P>
<B><P>DvdTs</B> demonstrates the use of WDM Kernel Streaming services to support
high-performance video/audio playback. A low-level Toshiba proprietary decoder
hardware support library, <B>DvdTDCod.lib,</B> is supplied with the DDK in binary form only,
but Toshiba has permitted us to publish all the source code that demonstrates the
architecture of an OEM MPEG2/AC-3 DVD minidriver and its interaction with Microsoft
kernel streaming services.</P>
</FONT><FONT FACE="Verdana"><H3>BUILDING THE SAMPLE</H3>
</FONT><FONT FACE="Verdana" SIZE=2><P>The sample is built with the standard DDK BUILD
utility in the standard checked or free DDK build environment. The Sources file links
to a special library,<B> DvdTDCod.lib</B>, supplied with the DDK in binary form only,
that encapsulates Toshiba proprietary decoder hardware-specific register definitions
and low-level support routines. These would vary with each OEM's hardware.</P>
<P>An installation file, <B>DvdTs.inf</B>, is provided. DvdTs.sys may be installed by
creating an OEM Installation Directory containing the DvdTs.sys binary and DvdTs.inf.
On machines with Toshiba DVD players, Windows 98 or Windows 2000 will have
already installed the default core OS driver, TosDvd.sys. Simply go into Device
Manager properties for Toshiba DVD Decoder Card Driver, hit the <B>Update Driver</B> button, and then specify your install directory containing DvdTs.inf and DvdTs.sys.</P>
<P>The DvdTs.sample is completely contained in one directory. There is no special
test application; just install the new driver and start watching a movie. Note that
DvdTs will only be started for DVD playback; if a standard CD-ROM or audio CD is
put in the DVD drive, DvdTs (or TosDvd in the default OS environment) will <I>not</I> be
started; a different minidriver module for CD-ROM or audio will be loaded by the OS.</P>
</FONT><FONT FACE="Verdana"><H3>RESOURCES</H3>
</FONT><FONT FACE="Verdana" SIZE=2><P>Check the DDK documentation in <b>DVD Driver
Model Design Notes</b> in the WDM DDK documentation for more general discussion of DVD
architecture, particularly as it relates to Microsoft DirectShow® and other Microsoft
multimedia technologies.</P>
<P>For background on WDM streaming architecture, see <b>Kernel-Mode Streaming Reference</b>
and the <b>Stream Class Driver Reference</I> in the DDK documentation.</b>
</FONT><FONT FACE="Verdana"><H3>CODE TOUR</H3>
<H4>File Manifest</H4>
<P><! ---------------- Snip Snip ---------------- ></P>
</FONT><U><PRE>File Description
</U>DvdTs.htm The documentation for this sample (this file).
<FONT FACE="Courier">SOURCES The generic file for building the code sample.
DvdTs.inf The .inf file for installing the code sample.
Debug.h Header for debug output routines for debug-only build.
Debug.c Debug output routines for debug-only build.
Que.h Header for stream request-queuing routines.
DevQue.c Source code for stream request-queuing routines.
Dvd.rc Used to store version information.
DvdCmd.c Main command processing module; set/get device KS_ properties.
DvdCmd.h Function prototypes for DvdCmd.c.
DvdInit.c Contains DriverEntry(), other device initialization code.
DvdInit.h Driver extension definition, various other structures and prototypes.
DvdIrq.c Device hardware interrupt logic.
Makefile Standard DDK build environment makefile.
DvdTDcod.h Header for DvdTDcod.lib, Toshiba-proprietary hardware routines.
Strmid.h Stream, property, and other KS_ kernel streaming descriptors and definitions.
</FONT><FONT FACE="Verdana"> </PRE>
<! ---------------- End, Snip Snip ---------------- >
</FONT><H3>Programming Tour</H3>
<FONT FACE="Verdana" SIZE=2><P>
WDM streaming enables more efficient data streaming by requiring
fewer transitions between user and kernel modes. In this sample, all streaming is in kernel mode,
the source is a DVD disk,
the video decoder is MPEG2, and the audio decoder is either MPEG audio, AC-3, or nonexistent
if the disk contains PCM audio.
</FONT><FONT SIZE=2>. </P>
</FONT><FONT FACE="Verdana" SIZE=2><P>
Video data from a DVD disk is accessed via the
UDF file system on command from the ActiveMovie file reader. The DVD stream is then
split into its components, and the MPEG video data is routed to an ActiveMovie
decoding filter. The data is then sent to hardware via a streaming WDM class driver
miniport specific to the MPEG video decoding hardware. The output of the decoding
hardware is sent directly to the frame buffer of the graphics card via a streaming
WDM interface using the Video Port extensions of Microsoft DirectDraw®.
</P>
<P>The configuration for audio decoding is basically the same.
AC-3 audio is split out by the DVD splitter and then passed to AC-3 decoder hardware
via a streaming WDM miniport of the AC-3 class driver. The output of the hardware
decoder (multichannel audio) is passed to a WDM streaming driver for the audio card.
The transport for the data movement is decided on by the WDM mechanism.
This particular driver is not even loaded by the OS for standard audio or data CD playback.
You will not see DvdTs activated until a DVD disk is inserted in the drive.
</P>
<P>The Toshiba decoder card is a multifunction card with both video and audio decoding on the same physical card.
At run time, a stream is a set of entry points into the driver that can receive or return sequential
packets of related data. For example, a DVD driver might have the following streams: video
in, video out, audio in, audio out, subpicture in, close captioning out. If the driver were
viewed as a component in a data flow diagram, each stream would correspond to a data line
going into or coming out of the driver.</P>
<P>A driver supports a fixed number of streams. At run time, the system can ask the driver
to instantiate any of its streams. Theoretically, a driver can allow the system to instantiate
a stream more than once, if the hardware is capable of handling multiple parallel streams of
that type of data. However, most current DVD decoders can only support one instance of each
stream. When a stream is opened, some structures are created to represent the stream.
Pointers to these structures are then passed around between the driver and the system,
so that the driver code knows which stream it is being executed for.</P>
<B>DriverEntry()</B> is the initial entry point into the driver called by the I/O subsystem.
A stream class client minidriver's DriverEntry() routine has two main functions to perform: <br>
<br> <B>1)</B> Allocate and fully initialize a <B>HW_INITIALIZATION_DATA </B> structure, and
<br><B> 2)</B> call
<B>StreamClassRegisterDriver() </B>with that structure and the DriverObject and RegistryPath
passed into DriverEntry() as input parameters . <br><br>
The following is a description of the fields in HW_INITIALIZATION_DATA
that must be filled out. All others not used must be zero-initialized. <P>
The first group are entry points for the mini Driver. All entry routines will be called
at High priority. If the driver has a task that requires a large amount
of time to accomplish (e.g. double buffer copying of large amounts of
data) The driver should request a callback at lower priority to perform the
desired function. Synchronization and re-entrancy issues are discussed later.
<p> The <B>HwInterrupt</B> field is set to the minidriver's main interrupt service routine.
If there is no such routine, the field must be set to NULL.
</p>
<P><PRE><FONT FACE="Courier">
HwInitData.HwInterrupt = (PHW_INTERRUPT)HwInterrupt; // ISR routine
</FONT></PRE></P>
The <B>HwReceivePacket</B> field describes the entry point for receiving an SRB
Request from the stream class driver that is a request to the adapter, as
opposed to the stream based request handlers that are initialised in the
OpenStream function
<P><PRE><FONT FACE="Courier">
HwInitData.HwReceivePacket = AdapterReceivePacket;
</FONT></PRE></P>
<B>AdapterReceivePacket()</B> is the main entry point used by the system to communicate with the driver after it is initialized.
When the system calls AdapterReceivePacket(), it passes it a pointer to an SRB (stream request block)
structure. This structure (full name: <B>HW_STREAM_REQUEST_BLOCK</B>) is defined in strmini.h and
contains information that tells the driver what is being requested. One of the members is an
integer SRB ID, which tells the driver what type of request this is.
Some of the many SRB request types are described below.
<P>	<B>SRB_INITIALIZE_DEVICE</B>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -