The IMediaStream interface provides access to the characteristics of a media stream, such as the stream's media type and purpose ID. It also has methods that create data samples.
For sample code which implements the multimedia streaming interfaces see Multimedia Streaming Sample Code.
When to Implement
Implement this interface when you want to add media type-specific functionality to your media stream. This interface is implemented on multimedia stream objects. IMediaStream provides generic sample-creation methods, but you usually want to write a more powerful version of these methods that will take advantage of your media type's specific characteristics.
When to Use
Use this interface when your application needs to access a stream's media type information and create data samples.
Methods in Vtable Order
IUnknown methods | Description |
QueryInterface | Retrieves pointers to supported interfaces. |
AddRef | Increments the reference count. |
Release | Decrements the reference count. |
IMediaStream methods | Description |
GetMultiMediaStream | Retrieves a pointer to the multimedia stream that contains the specified media stream. |
GetInformation | Retrieves the stream's purpose ID and media type. |
SetSameFormat | Sets the media stream the same format as a previous stream. |
AllocateSample | Allocates a new stream sample object for the current media stream. |
CreateSharedSample | Creates a new stream sample that shares the same backing object as the existing sample. |
SendEndOfStream | Forces the current stream to end. If the current stream isn't writable, this method does nothing. |
Allocates a new stream sample object for the current media stream.
HRESULT AllocateSample(
DWORD dwFlags,
IStreamSample **ppSample
)
Returns one of the following values.
Value | Meaning |
E_OUTOFMEMORY | There isn't enough memory available to create a stream sample. |
E_POINTER | A parameter is invalid. |
S_OK | Success; ppSample points to the new sample's IStreamSample interface. |
This method allocates the sample and its associated backing object or buffer. The backing object is either the DirectDraw surface for video or the IAudioData object for audio.
Creates a new stream sample that shares the same backing object as the existing sample.
HRESULT CreateSharedSample(
IStreamSample* pExistingSample,
DWORD dwFlags ,
IStreamSample** ppNewSample
)
Returns one of the following values.
Value | Meaning |
E_OUTOFMEMORY | There isn't enough memory available to create the sample. |
E_POINTER | One of the parameters is invalid. |
MS_E_INCOMPATIBLE | The existing sample isn't compatible with the specified media stream. |
S_OK | Success; ppNewSample points to the newly created sample. |
This method calls IUnknown::QueryInterface on the existing sample to retrieve the media type-specific information, which it uses to create the shared sample.
Retrieves the stream's purpose ID and media type.
HRESULT GetInformation(
MSPID* pPurposeId,
STREAM_TYPE* pType
)
Returns S_OK if successful or E_POINTER if one of the parameters is invalid.
You can set either parameter to null on entry, to indicate that the information isn't needed.
The value retrieved in the pPurposeId parameter will usually be either MSPID_PrimaryVideo, which identifies the primary video stream, or MSPID_PrimaryAudio, which identifies the primary audio stream, however other values may be defined by developers if necessary.
Retrieves a pointer to the multimedia stream that contains the specified media stream.
HRESULT GetMultiMediaStream(
IMultiMediaStream** ppMultiMediaStream
)
Returns S_OK if successful or E_POINTER if ppMultiMediaStream is invalid.
This method increments the reference count of the returned object pointer.
Forces the current stream to end. If the current stream isn't writable, this method does nothing.
HRESULT SendEndOfStream(
DWORD dwFlags
)
Returns S_OK if successful or MS_E_INCOMPATIBLE if the existing sample isn't compatible with the current media stream.
Applications do not call this internal method.
Sets the media stream the same format as a previous stream.
HRESULT SetSameFormat(
IMediaStream *pStreamThatHasDesiredFormat,
DWORD dwFlags
);
Returns S_OK if successful or E_POINTER if one of the parameters is invalid.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.