IWMEncAudienceObj::put_AudioBufferMax

Windows Media Encoder SDK banner art

The put_AudioBufferMax method specifies the maximum size of the audio buffer for the current audience.

Syntax

HRESULT put_AudioBufferMax(
  short  iRenderSiteIndex,
  long  lBMax
);

Parameters

iRenderSiteIndex

[in]  short containing the audience stream index. Because an audience can only contain one stream of each type, iRenderSiteIndex must be zero.

lBMax

[in]  long that indicates the size of the audio buffer, in milliseconds.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Remarks

The get_AudioBufferMax method indicates the maximum time that a client must wait to play audio content that was encoded at peak variable bit rate (VBR).

Your audio buffer should always be equal to or less than your video buffer. For example, if you are using peak bit rate-based VBR audio and CBR video, the peak audio buffer size should be less than the video buffer size. If you are using peak bit rate-based VBR audio and peak bit rate-based video, the peak audio buffer size should be less than the peak video buffer size.

Example Code

// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"

    // Declare variables.
    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    IWMEncProfile2* pPro2;
    IWMEncAudienceObj* pAudnc;

    // Initialize the COM library and retrieve a pointer to an IWMEncoder interface.
    hr = CoInitialize(NULL);
    if ( SUCCEEDED( hr ) )
    {
        hr = CoCreateInstance(CLSID_WMEncoder,
            NULL,
            CLSCTX_INPROC_SERVER,
            IID_IWMEncoder,
            (void**) &pEncoder);
    }

    // Retrieve a specific profile.
    if ( SUCCEEDED( hr ) )
    {
        hr = pEncoder->get_ProfileCollection(&pProColl);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pProColl->Item(11, &pPro);
    }

    if ( SUCCEEDED( hr ) )
    {
        hr = CoCreateInstance(CLSID_WMEncProfile2,
            NULL,
            CLSCTX_INPROC_SERVER,
            IID_IWMEncProfile2,
            (void**) &pPro2);
    }

    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->LoadFromIWMProfile(pPro);
    }

    // Retrieve the first audience in the profile.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->get_Audience(0, &pAudnc);
    }

    // Specify the maximum size of the audio buffer.
    long lAudBMax = 7000; // 7 seconds
    if ( SUCCEEDED( hr ) )
    {
        hr = pAudnc->put_AudioBufferMax(0, lAudBMax);
    }

    // Release pointers.
    if ( pAudnc )
    {
        pAudnc->Release();
        pAudnc = NULL;
    }
    if ( pPro2 )
    {
        pPro2->Release();
        pPro2 = NULL;
    }

Requirements

Header: wmencode.h

Library: wmenc.exe

See Also