## C/C++-based Sample Applications

This article details sample applications that are written in C++ or C. The sample applications implement media players or perform other application-related functions. The differences between them are mainly the different programming languages, API, or frameworks used.

Some of these samples use the Microsoft® Foundation Classes (MFC).

Contents of this article:

- AMCap Sample (DirectShow Capture Application)
- CPlay Sample (C/COM-based Media Player Application)
- Dvdsampl Sample (DVD Player Application)
- InWindow Sample (Window Playback Application)
- IPlay Sample (Indeo Player Application)
- MFCPlay Sample (C++/COM-based Media Player Application)
- MPEGProp Sample (MPEG Property Page Display Application)
- PlayFile Sample (Simple Playback Application)
- ShowStrm Sample (Multimedia Streaming Application)
- VidClip Sample (Video Editing Application)

AMCap Sample (DirectShow Capture Application)

The DirectShow capture sample, AMCap, demonstrates the basics of capturing audio and video from a hardware source to a specified output file or to a preview window.

To see a list of the hardware capture devices on your system, choose the Devices menu; DirectShow uses the ICreateDevEnum interface to create the list of devices that appears. After choosing a device, choose the Set Frame Rate command from the Capture menu and set the desired frame rate; the default value is 30 frames per second. To set an output file for your capture, pick the Set Capture File command from the File menu. DirectShow uses the File Writer filter to associate your specified file with the capture session.

If you want to turn audio capturing on or off, choose the Capture Audio command from the Capture menu. To turn capture previewing on or off, choose the Preview command from the Options menu. When you are ready to begin capturing, choose the Start Capture command from the Capture menu. If you want to save your captured data to a file other than the specified output file, choose the Save Captured Video As command from the File menu.

Note: Before you begin capturing for the first time, choose Allocate File Space from the File menu to preallocate the capture file. Preallocating the file improves capture performance. AMCap calls AllocCapFile to preallocate the capture file.

Sample Locations

CPlay Sample (C/COM-based Media Player Application)

This C/COM-based media player sample, CPlay, is a simple application that renders multimedia files using DirectShow™ from within the C language. The CPlay sample does not use Microsoft Foundation Classes (MFC). If you want to see a sample that uses MFC, see MFCPlay Sample (C++/COM-based Media Player Application). The CPlay sample shows how to utilize the DirectShow components without using the base classes provided with DirectShow. The sample creates a filter graph (by calling CoCreateInstance to get a pointer to the IGraphBuilder interface), and requests the filter graph to render a file. The filter graph is then controlled by using the IMediaControl interface. This sample also uses the IMediaEvent and IMediaPosition interfaces.

CPlay is a minimal application that implements the following menu commands: Open, Play, Pause, Stop, and Exit on the File menu, and About on the Help menu.

Sample Locations

Dvdsampl Sample (DVD Player Application)

The DirectShow DVD sample player, Dvdsampl, is a simple application that plays DVD Video content. It uses the IDvdGraphBuilder interface to build a DVD filter graph and to obtain interface pointers for IAMLine21Decoder, IDvdControl, and IDvdInfo. It uses those interfaces and enables you to turn closed captioning on and off, play in full screen mode, and display and select from DVD menus.

Note: Your system must include DVD playback hardware to run this sample.

Sample Locations

InWindow Sample (Window Playback Application)

The InWindow application is a simple sample that shows minimal code required to play back a media file into a specific window. It builds on the PlayFile sample. Like PlayFile, it provides a file Open dialog box that enables you to open media files. It also uses IGraphBuilder, IMediaEventEx, and IMediaControl as PlayFile does. InWindow expands on the PlayFile functionality by calling IVideoWindow::put_Owner, IVideoWindow::put_WindowStyle, and IVideoWindow::SetWindowPosition to direct playback into the main application window.

Sample Locations

IPlay Sample (Indeo Player Application)

The Intel® Indeo player sample, IPlay, uses DirectShow to render multimedia files and demonstrates the Indeo Video Interactive application programming interfaces (API). IPlay demonstrates how to access the advanced features of the Indeo Video Interactive (IVI) codec. It is a simple application written in C++ using Microsoft Foundation Classes (MFC). If the file is an IVI format file, it enables controls for the IVI advanced features. The advanced features include local decoding, a decoding time limit, and the ability to adjust brightness, saturation, and contrast.

The Ax_spec.h file defines the interfaces of the IVI codec. The CIPlayDoc::OnOpenDocument function demonstrates how to determine if a file is an IVI format file. The CIPlayDoc::Getxxx and CIPlayDoc::Setxxx functions demonstrate how to get and set the IVI playback parameters for the advanced features.

This sample uses the following interfaces:

- IGraphBuilder — to create a filter graph and render a file
- IFilterGraph — to enumerate the filters in the filter graph
- IMediaControl — to play/pause/stop the playback
- IMediaEvent — to be notified of EC_COMPLETE (playback complete) and other events
- IMediaPosition — to set the time that the media stream begins
- IVideoWindow — to set the window size/caption/position
- IBasicVideo — to get the native window size.

IPlay also implements and uses the IIndeoDecode interface (not part of DirectShow).

Sample Locations

MFCPlay Sample (C++/COM-based Media Player Application)

The C++/COM-based media player sample, MFCPlay, is a simple application that renders multimedia files using DirectShow from within C++ and Microsoft Foundation Classes (MFC). It demonstrates how to connect the DirectShow components by using the interfaces provided with DirectShow and MFC. The sample creates a filter graph (by calling CoCreateInstance to get a pointer to the IGraphBuilder interface), and requests the filter graph to render a file. The filter graph is then controlled by using the IMediaControl interface. This sample also uses the IMediaEvent and IMediaPosition interfaces.

The MFCPlay application implements the following menu commands: Open, Play, Pause, Stop, and Exit on the File menu, and About on the Help menu.

Sample Locations

MPEGProp Sample (MPEG Property Page Display Application)

The MPEGProp sample application demonstrates how to display a filter's property page.

When you open MPEGProp, choose Open from the File menu and select an MPEG media file from the standard Open dialog box. After you select an appropriate file, MPEGProp calls CoCreateInstance to create a new filter graph and renders the chosen source file. MPEGProp calls IFilterGraph::FindFilterByName to locate the MPEG Video Codec filter, and then calls OleCreatePropertyFrame with the codec pointer to display the filter's property page.

Sample Locations

PlayFile Sample (Simple Playback Application)

The PlayFile application is a simple sample that shows minimal code required to play back a media file. It provides a file Open dialog box that enables you to open files including file types such as AVI, MPEG, MOV, and QT. PlayFile uses the IGraphBuilder::RenderFile method to render the filter graph for the chosen media file, IMediaEventEx to handle signaling of events, IMediaControl::Run to play the resulting filter graph, and IMediaControl::Stop to stop playback. The sample calls IVideoWindow to control whether the playback window is visible. Video follows the default behavior and plays back in a separate window rather than in the main application window.

See InWindow Sample (Window Playback Application) for a sample that builds on PlayFile and plays back video into the main application window.

Sample Locations

ShowStrm Sample (Multimedia Streaming Application)

The ShowStrm application demonstrates how to use a Microsoft® DirectDraw® surface to blit a multimedia stream. It is a console application that sends a movie out to the surface when invoked from the command line with the following syntax:

    SHOWSTRM Name_of_Movie

For example, to play Angry.avi, you could use the command:

    C:\>SHOWSTRM angry.avi

Sample Locations

VidClip Sample (Video Editing Application)

The VidClip application demonstrates how to use the multimedia streaming interfaces and how to support rudimentary video editing. The VidClip sample reads from multiple streams and writes to a single stream. For more information on the multimedia streaming interfaces, see List of Multimedia Streaming Interfaces.

On the Video menu in the VidClip application, choose the Add Clip command to add clips to your list; you can include start and stop times, if you want to add only a portion of a clip. Choose the Edit Clip command to edit existing clips in the list, and the Delete Clip command to delete clips. The Make a Movie command combines the clips into one stream.

On the File menu, choose the Settings command to set the height, width, depth, and compression for the stream data. Choose the Save command to save the settings to a file in your project.

Sample Locations

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.