CSourceStream Class (Compact 2013)

3/26/2014

Ee495032.5a3b9faf-5642-4aa6-b2a9-6b06b953b2d2(en-us,WinEmbedded.80).gif

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 loops, 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 fails.

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

Header

dshow.h,
Streams.h

Library

ole32.lib,
Ole32auth.lib,
Strmbase.lib,
Strmiids.lib,
uuid.lib

See Also

Reference

DirectShow Classes