Export (0) Print
Expand All

How to Determine Supported Rates

Before changing the playback rate, an application should check whether the playback rate is supported by the objects in the pipeline. The IMFRateSupport interface provides methods to get the maximum forward and reverse rates, the supported rate nearest to a requested rate, and the slowest rate. Each of these rate queries can specify the playback direction and whether to use thinning. The exact playback rate is queried by using the IMFRateControl interface.

For information about changing playback rates, see How to Set the Playback Rate on the Media Session.

For general information about playback rates, see About Rate Control.

To determine the current playback rate

  1. Get the rate control service from the Media Session.

    
    IMFRateControl *pRateControl = NULL;
    hr = MFGetService(
           pMediaSession, 
           MF_RATE_CONTROL_SERVICE,
           IID_IMFRateControl, 
           (void**) &pRateControl );
    
    

    Pass an initialized IMFMediaSession interface pointer in the punkObject parameter of MFGetService.

    The application must query for the rate control service through the Media Session. Internally, the Media Session queries the objects in the topology.

  2. Call the IMFRateControl::GetRate method to get the current playback rate.

    
    hr = pRateControl->GetRate(&bThin, &rate);
    
    

    The pfThin parameter of GetRate receives a BOOL value that indicates whether the stream is currently being thinned. The application must pass NULL if it does not want to query thinning support for the stream. The pflRate parameter receives the current playback rate.

To determine the nearest supported rate

  1. Get the rate support service from the Media Session.

    
    IMFRateSupport *pRateSupport = NULL;
    hr = MFGetService(
           pMediaSession, 
           MF_RATE_CONTROL_SERVICE,
           IID_IMFRateSupport, 
           (void**) &pRateSupport );
    
    

    Pass an initialized IMFMediaSession interface pointer in the punkObject parameter of MFGetService.

  2. Call the IMFRateSupport::IsRateSupported method to retrieve the supported rate nearest to a requested playback rate.

    
    float rateRequested = 4.0;
    float actualRate = 0;
    hr = pRateSupport->IsRateSupported(
           TRUE, 
           rateRequested, 
           &actualRate );
    
    

    The example queries whether a playback rate of 4.0 is supported with thinning. This is indicated by passing TRUE in the fThin parameter of IsRateSupported. If this rate is supported, actualRate contains the playback rate of 4.0, and the call succeeds with a return value of S_OK. If the exact playback rate is not supported, the nearest supported rate is received in actualRate. If the rate is not supported and there is no available nearest playback rate, the call returns an appropriate error code.

    These values can change depending on which pipeline components are loaded. Therefore, you should query the values again whenever you load a new topololgy.

    If the desired playback rate is not supported, one option is to query each object in the topology individually, to find out if a particular component does not support the rate. You might be able to rebuild the topology without this component and then play at the desired rate. For example, if every component except the audio renderer supports a given rate, you could rebuild the topology without the audio branch and play at the desired rate without audio.

To determine the slowest supported rate

  1. Get the rate support service from the Media Session.

    
    IMFRateSupport *pRateSupport = NULL;
    hr = MFGetService(
           pMediaSession, 
           MF_RATE_CONTROL_SERVICE,
           IID_IMFRateSupport, 
           (void**) &pRateSupport );
    
    

    Pass an initialized IMFMediaSession interface pointer in the punkObject parameter of MFGetService.

  2. Call the IMFRateSupport::GetSlowestRate method to retrieve the slowest supported rate.

    
    float slowestRate = 0;
    hr = pRateSupport->GetSlowestRate(
           MFRATE_REVERSE, 
           TRUE, 
           &slowestRate);
    
    

    The example queries for the slowest reverse playback rate with thinning. The lower bound rate is received in slowestRate parameter of GetSlowestRate.

    If reverse playback or thinning is not supported, the call returns an appropriate error code.

Related topics

Media Session
Rate Control
Seeking, Fast Forward, and Reverse Play

 

 

Community Additions

ADD
Show:
© 2014 Microsoft