Share via


CSourceStream Class

Derive from this class to provide a class that creates the data stream from one of the output pins. It should be used with an object that is derived from the CSource class derived object to provide the filter-level object.

The CSourceStream class creates a worker thread to push data downstream when the filter enters a paused or running state. The thread first calls the CSourceStream::OnThreadCreate member function. If this succeeds, it will loop, calling the CSourceStream::FillBuffer member function until the CSourceStream::Inactive member function stops it. As the thread quits, it calls the CSourceStream::OnThreadDestroy member function. If OnThreadCreate fails, OnThreadDestroy is called, and the active member function will fail.

To use the CSourceStream class, supporting a single media type, carry out the following steps.

Override the CSourceStream::GetMediaType member function to report the supported output format.

Override the CSourceStream::FillBuffer member function with a means of filling out each IMediaSample object with data.

To use the CSourceStream class, supporting multiple media types, carry out the following steps.

Override the CSourceStream::CheckMediaType and CSourceStream::GetMediaType member functions to report the supported media types (for more information, see the CBaseMediaFilter class).

Override the CSourceStream::FillBuffer member function with a means of filling out each IMediaSample object with data.

See the files in the Samples\Multimedia\DShow\Src\Ball subdirectory in the DirectX Media Software Development Kit (SDK) for an example of a pin supporting multiple types.

If you want more complex management of your worker thread, you can override most of the associated member functions. See Samples\Multimedia\DShow\Src\Vidcap in the DirectX Media SDK for an example.

Member Functions

Member function Description
Active Called by the CBaseMediaFilter class to start the worker thread.
CheckRequest Determines if a command is waiting for the thread.
CSourceStream Constructs a CSourceStream object.
Exit Called by the CSourceStream::Inactive member function to exit the worker thread.
GetRequest Retrieves the next command for the thread.
Inactive Called by the CBaseMediaFilter member function to shut down the worker thread.
Init Called by the CSourceStream::Active member function to initialize the worker thread.
Pause Pauses the stream of the worker thread. This will acquire all necessary resources.
Run Starts the worker thread generation of a media sample stream.
Stop Stops the stream.

Overrideable Member Functions

Member function Description
CheckMediaType Determines if a specific media type is supported. Override this member function if you use multiple types.
DoBufferProcessingLoop Loops, collecting a buffer and calling the CSourceStream::FillBuffer processing function.
FillBuffer Override this member function to fill the stream buffer during the creation of a media sample.
GetMediaType Retrieves the media type or types that this pin supports; override the appropriate version of this member function to support one or multiple media types.
OnThreadCreate Called as the worker thread is created; override this member function for special processing.
OnThreadDestroy Called during the destruction of a worker thread; override this member function for special processing.
OnThreadStartPlay Called at the start of processing Pause or Run command; override this member function for special processing.
ThreadProc Override this member function to create a custom thread procedure.

Implemented IPin Methods

Method Description
QueryId Retrieves an identifier for the pin.

Requirements

DirectShow applications and DirectShow filters have different include file and link library requirements. See Setting Up the Build Environment for more information.

OS Versions: Windows CE 2.12 and later. Version 2.12 requires DXPAK 1.0 or later.
Header:

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.