Figure 1   Current DirectX Components

Component
Description
DirectDraw
2D graphics, including memory management, fast bit block transfers, overlays, and flips, all compatible with GDI.
DirectSound
Capturing, mixing, and playing sounds.
DirectShow
Playback of multimedia audio and video streams and files, and support for multimedia codecs.
Windows Media Player
ActiveX controls for playback of all major multimedia types using DirectShow.


Figure 2   Future DirectX Components

Component
Description
DirectMusic
Composition and playback of message-based musical data.
Direct3D Immediate Mode (IM)
Interactive 3D graphics and rendering.
DirectPlay
Networked multi-player gaming.
DirectInput
Personal input devices, including force feedback (already available as part of the core Windows CE 2.12 release).
Windows Media Services client filters and codecs
Multimedia streaming over the Internet, including support for low-bandwidth connections using MSAudio and Microsoft MPEG-4 video.


Figure 3   DirectDraw 6.1 Interfaces

Interface
Description
IDirectDraw4
Creates and manages DirectDraw objects: sets cooperative levels; controls the display device; gets caps; changes display mode; creates surfaces and palettes; and accesses GDI surfaces.
IDirectDrawSurface4
Implements fast blts; associates palettes; locks and unlocks surface memory; supports overlays and page flipping; interfaces with GDI; attaches and detaches surfaces.
IDirectDrawPalette
Assigns color mapping and colors to a palette.
IDirectDrawClipper
Assigns rectangles to a surface to stencil the valid drawing area for the destination buffer.
IDirectDrawColorControl
Provides TV-like color controls for a surface.
IDirectDrawGammaControl
Controls display intensity gamma correction.
IDirectDrawVideoPort
Gives a video stream direct access to DirectDraw hardware surface memory.
IDirectDrawVideoPortContainer
Creates and manipulates video ports.
IDirectDrawSurface5
Supports AlphaBlt.


Figure 4   DirectSound 6.1 Interfaces

Interface
Description
IDirectSound
Creates and manages DirectSound objects: sets cooperative levels; gets caps; creates sound buffers; sets speaker configurations.
IDirectSoundBuffer
Creates and manipulates sound playback buffers.
IDirectSoundCapture
Creates a sound capture buffer.
IDirectSoundCaptureBuffer
Manipulates a sound capture buffer.
IDirectSoundNotify
Sets up notification events for a capture or playback buffer.


Figure 6   A DirectShow Video Player


HRESULT PlayMovie(LPTSTR lpszMovie)
{ 
// we will use several DirectShow interfaces
IMediaControl *pMC = NULL; 
IGraphBuilder *pGB = NULL;
IMediaEventEx *pME = NULL;

long evCode; // something to hold a returned event code

// instantiate a filter graph as in-proc server
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IMediaControl, (void **)&pMC);

// we'll use this interface to build the graph
hr = pMC->QueryInterface(IID_IGraphBuilder, (void **)&pGB);

// we'll want to wait for completion of the rendering, so we need a media event interface
hr = pMC->QueryInterface(IID_IMediaEventEx, (void **)&pME);

// now we're ready to build the filter graph based on the source file data types
hr = pGB->RenderFile(lpszMovie, NULL);

// play  the source file
hr = pMC->Run();

// block application until video rendering operations finish
hr = pME->WaitForCompletion(INFINITE, &evCode);

// release interfaces
}

Figure 7   Codecs Available

Audio File Types
Codecs
AIFF, Au, Wave
PCM, ADPCM, mu-law, and A-law
MIDI
N/A (uses MIDI)
MPEG-1
Microsoft MPEG-1 audio layers
ASF, ASX
MSAudio 4.0, ACELP.net, Voxware MetaSound
Video File Types
Codecs
AVI
Cinepak
MOV
Cinepak
MPEG-1
MPEG-1
MPEG-4
MPEG-4 V3
ASF, ASX
MPEG-1, Microsoft MPEG-4 V3, Cinepak


Figure 8   DirectShow Filters

Filter
Description
ACM Audio Compressor
Acts as a container for the ACM, integrating the ACM with the DirectShow architecture.
Audio Renderer
Generic audio rendering filter that you can connect to the output of any of the following filters if they contain WAV audio: File Source (Async), File Source (URL), MPEG-1 Stream Splitter, AVI Splitter, WAVE Parser, or any audio transform filter.
AVI Decompressor
Decompresses AVI video input and generates suitable output for a video rendering filter or an intervening video transform filter.
AVI Splitter
Parses AVI-compressed video data and splits it into the component data streams.
Color Space Converter
A transform filter that converts from one RGB color type to another, such as between 24-bit and 8-bit RGB color.
DSound Audio Renderer
A generic audio rendering filter that you can connect to the output of any of the following filters if they contain WAV audio: AVI Splitter, WAVE Parser, or any audio transform filter.
File Source (Async)
A generic asynchronous source filter that works with any source file whose media major type is stream. This includes AVI, MOV, MPEG, and WAV files.
File Source (URL)
A generic asynchronous source filter that works with any source file that can be identified by a URL and whose media major type is stream. This includes AVI, MOV, MPEG, and WAV files.
MIDI Parser
Parses MIDI data from the File Source (Async) and File Source (URL) filters.
MIDI Renderer
Renders MIDI data from the MIDI Parser filter.
MPEG Audio Decoder
Decompresses MPEG-1 audio data.
MPEG Video Decoder
Decompresses MPEG-1 video data.
MPEG-1 Stream splitter
Splits MPEG-1 data into separate audio and video streams.
Quicktime Movie Parser
Splits Apple QuickTime data into audio and video streams.
Video Renderer
A Generic video renderer that connects to any video transform filter that produces decompressed video data. This filter has its own plug-in distributor in the filter graph manager, which enables applications to set and retrieve properties on the filter by calling the corresponding interface methods on the filter graph manager.
WAVE Parser
Parses WAV-format audio data.


Figure 10   Dreamcast DirectX Components

DirectX Components
Main Differences on Dreamcast
DirectDraw
Full-Screen Exclusive Mode Only. IDirectDrawClipper not supported. Overlay surfaces not supported.
Direct3D IM
Dreamcast-specific flags used to expose some PowerVR features. Frame buffer cleared after each frame. No Z-buffer on PowevVR.
Direct3D Retained Mode
Not Supported.
DirectSound
No software mixing.
DirectMusic
Planned for full support later this year.
DirectInput
Buffered data not supported. Must poll for immediate data. Force feedback not supported.
DirectPlay
IPX protocol not supported.
DirectShow
No audio or video capture support. Control of DVD players and VCRs not supported. No cutlist support. No property pages or resource manager.


Figure 12   D3DSTRM Sample


bool UpdateStreamSample(IDirectDrawStreamSample* lpddss) {

    HRESULT hr;

    // Update the sample only if the application is active
    if (!g_bActive) {
        return true;
    }

    // If we are seeking, update the stream clock
    if (g_stOffset) {
        g_stTime += g_stOffset;
        g_lpmmsStream->Seek(g_stTime);
    }

#ifdef RENDER_TO_DEVICE_MEMORY
    // Make sure the flip has completed before changing texture contents or
    // we risk a render timeout
    do {
        hr = g_lpddsFront->GetFlipStatus(DDGFS_ISFLIPDONE);
    } while (hr == DDERR_WASSTILLDRAWING);

    if (ResultFailed(hr, TEXT("IDirectDrawSurface::GetFlipStatus"))) {
        return false;
    }
#endif // RENDER_TO_DEVICE_MEMORY

    // Update the texture with the contents of the video stream
    hr = lpddss->Update(0, NULL, NULL, 0);
    if (hr != MS_E_NOTRUNNING && FAILED(hr)) {
        ResultFailed(hr, TEXT("IDirectDrawStreamSample::Update"));
        return false;
    }

    // If we've reached the end of the stream, reset it
    if (hr == MS_S_ENDOFSTREAM) {
        if (WaitForSingleObject(g_hEOS, 0) == WAIT_OBJECT_0)
        {

            hr = g_lpmmsStream->Seek(0);
            if (ResultFailed(hr, TEXT("IMultiMediaStream::Seek"))) {
                return false;
            }
        }

        hr = lpddss->Update(0, NULL, NULL, 0);
        if (hr != MS_E_NOTRUNNING && FAILED(hr)) {
            ResultFailed(hr, TEXT("IDirectDrawStreamSample::Update"));
            return false;
        }
    }

#ifndef RENDER_TO_DEVICE_MEMORY

    if (g_lpddsStreamTarget && g_bStretchStream) {
        hr = g_lpddsSystemMemory->Blt(&g_rectTexture, g_lpddsStreamTarget, 
                                      &g_rectStream, DDBLT_WAIT, NULL);
        if (ResultFailed(hr, TEXT("IDirectDrawSurface::Blt"))) {
            return false;
        }
    }

    // Load the source texture into the destination
    hr = g_lpd3dtDeviceMemory->Load(g_lpd3dtSystemMemory);
    if (FAILED(hr)) {
        if (hr != DDERR_SURFACELOST) {
            ResultFailed(hr, TEXT("IDirect3DTexture2::Load"));
            return false;
        }
    }

#endif // !RENDER_TO_DEVICE_MEMORY

    return true;
}