Service Interfaces

Some interfaces in Media Foundation must be obtained by calling IMFGetService::GetService instead of by calling QueryInterface. The GetService method works like QueryInterface, but with the following differences:

  • It takes a service identifier GUID in addition to the interface identifier.
  • It can return a pointer to another object that implements the interface, instead of returning a pointer to the original object that is queried.

Note

The IMFGetService interface is very similar to the IServiceProvider interface used in some other APIs.

 

A service is a particular interface obtained from a particular class of objects through the IMFGetService interface. The following services are defined.

Service identifier Interface Objects that might expose this service
MF_METADATA_PROVIDER_SERVICE IMFMetadataProvider Media sources
MF_MEDIASOURCE_SERVICE IMFMediaSource Supported in Windows 8.1 and later.
MF_PMP_SERVER_CONTEXT IMFPMPServer Protected media path (PMP) Media Session.
MF_QUALITY_SERVICES IMFQualityAdvise Media sources.
MF_RATE_CONTROL_SERVICE IMFRateControl Media sources, Media Session
MF_RATE_CONTROL_SERVICE IMFRateSupport Media sources, media sinks, Media Session
MF_REMOTE_PROXY IMFRemoteProxy Proxies for remote objects.
MF_SAMI_SERVICE IMFSAMIStyle Synchronized Accessible Media Interchange (SAMI) media source.
MF_SOURCE_PRESENTATION_PROVIDER_SERVICE IMFMediaSourcePresentationProvider Sequencer source
MF_TIMECODE_SERVICE IMFTimecodeTranslate ASF media source.
MF_TOPONODE_ATTRIBUTE_EDITOR_SERVICE IMFTopologyNodeAttributeEditor Media session
MF_WRAPPED_OBJECT IMFByteStream Wrapped objects
MF_WRAPPED_BUFFER_SERVICE Supported in Windows 8.1 and later.
MF_WRAPPED_SAMPLE_SERVIC Supported in Windows 8.1 and later.
MF_WORKQUEUE_SERVICES IMFWorkQueueServices Media session
MFNET_SAVEJOB_SERVICE IMFSaveJob Byte streams
MFNETSOURCE_STATISTICS_SERVICE IPropertyStore Network source. Use this service to retrieve network statistics. See MFNETSOURCE_STATISTICS Property.
MR_AUDIO_POLICY_SERVICE IMFAudioPolicy Audio renderer
MR_BUFFER_SERVICE IDirect3DSurface9 DirectX surface buffers
MR_CAPTURE_POLICY_VOLUME_SERVICE IMFSimpleAudioVolume Audio capture source
MR_POLICY_VOLUME_SERVICE IMFSimpleAudioVolume Audio renderer
MR_STREAM_VOLUME_SERVICE IMFAudioStreamVolume Audio renderer
MR_VIDEO_ACCELERATION_SERVICE IDirect3DDeviceManager9, IDirectXVideoAccelerationService Enhanced video renderer (EVR)
MR_VIDEO_ACCELERATION_SERVICE IDirectXVideoMemoryConfiguration Input pins on the DirectShow EVR filter
MR_VIDEO_ACCELERATION_SERVICE IMFVideoSampleAllocator Interface EVR stream sinks.
MR_VIDEO_MIXER_SERVICE Various interfaces exposed by the EVR mixer. See Using the Video Mixer Controls. EVR
MR_VIDEO_RENDER_SERVICE Various interfaces exposed by the EVR presenter. See Using the Video Display Controls. EVR
MF_ACOUSTIC_ECHO_CANCELLATION_CONTROL_SERVICE IAcousticEchoCancellationControl Acoustic Echo Cancellation (AEC) effects. Introduced in Windows 11, version 24H2.
MF_AUDIO_EFFECTS_MANAGER_SERVICE IAudioEffectsManager Media sources. Introduced in Windows 11, version 24H2.

 

You must use GetService to get the interfaces listed in this table from the objects listed in this table.

In some cases, an interface is returned as a service by one class of objects, and returned through QueryInterface by another class of objects. The reference pages for each interface indicate when to use GetService and when to use QueryInterface.

Caution

An object might be implemented in such a way that it returns a service interface through QueryInterface as well as GetService. However, using QueryInterface when GetService is required might lead to compatibility problems later.

 

The MFGetService function is a helper function that queries an object for IMFGetService and then calls the object's GetService method.

Examples

The following example queries the Media Session for IMFGetService and gets the IMFRateControl interface.

IMFGetService *pGetService = NULL;
IMFRateControl *pRateControl = NULL;
HRESULT hr = S_OK;

hr = pMediaSession->QueryInterface(
    IID_IMFGetService, 
    (void**)&pGetService);

if (SUCCEEDED(hr))
{
    hr = pGetService->GetService(
        MF_RATE_CONTROL_SERVICE, 
        IID_IMFRateControl,
        (void**)&pRateControl);
}
if (SUCCEEDED(hr))
{
    // Use IMFRateControl. (Not shown.)
}

// Clean up.
SAFE_REELEASE(pGetService);
SAFE_RELEASE(pRateControl);

The following example is equivalent to the previous example but uses the MFGetService function.

IMFRateControl *pRateControl = NULL;
HRESULT hr = S_OK;

hr = MFGetService(
    pMediaSession, 
    MF_RATE_CONTROL_SERVICE, 
    IID_IMFRateControl, 
    (void**) &pRateCtl 
); 
if (SUCCEEDED(hr))
{
    // Use IMFRateControl. (Not shown.)
}

// Clean up.
SAFE_RELEASE(pRateControl);

IMFGetService Interface

Media Foundation Platform APIs