Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
![]() |
The AddAudience method adds a new audience to the current profile.
Syntax
HRESULT AddAudience(
long lBitrate,
IWMEncAudienceObj** ppAudience
);
Parameters
lBitrate
[in] long containing the bit rate for the new audience, in bits per second (bps).
ppAudience
[out] Pointer to a pointer to an IWMEncAudienceObj interface containing the new audience.
Return Values
If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.
| Return code | Number | Description |
| E_POINTER | 0x80004003 | The indirect pointer to the audience is NULL. |
Remarks
An audience is a collection of settings specifying the bit rates for each stream, and additional settings depending on the types of streams in the profile. Profiles that use constant bit rate (CBR) mode can contain multiple audiences.
Example Code
// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"
HRESULT hr;
IWMEncProfile2* pPro2;
IWMEncAudienceObj* pAudnc;
long lAudCount;
int i;
// Initialize the COM library and retrieve a pointer to an IWMEncProfile2 interface.
hr = CoInitialize(NULL);
if ( SUCCEEDED( hr ) )
{
hr = CoCreateInstance(CLSID_WMEncProfile2,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncProfile2,
(void**) &pPro2);
}
// Verify profile settings immediately as they are set.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->put_ValidateMode(VARIANT_TRUE);
}
// Provide a name and description.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->put_ProfileName(CComBSTR("Sample MBR Profile"));
}
if ( SUCCEEDED( hr ) )
{
hr = pPro2->put_ProfileDescription(CComBSTR("A video profile with three audiences"));
}
// Specify video content.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->put_ContentType(16);
}
// Specify constant bit rate (CBR) mode.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->put_VBRMode(WMENC_VIDEO, 0, WMENC_PVM_NONE);
}
// Add audiences for 200, 400, and 600 Kbps.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->AddAudience(200000, &pAudnc);
}
if ( SUCCEEDED( hr ) )
{
hr = pPro2->AddAudience(400000, &pAudnc);
}
if ( SUCCEEDED( hr ) )
{
hr = pPro2->AddAudience(600000, &pAudnc);
}
if ( SUCCEEDED( hr ) )
{
hr = pPro2->get_AudienceCount(&lAudCount);
}
// Create an audience object then loop through all of the audiences
// in the current profile, making the same changes to each audience.
for (i = 0; i < lAudCount; i++)
{
if ( SUCCEEDED( hr ) )
{
hr = pPro2->get_Audience(i, &pAudnc);
}
// The Windows Media 9 codec is used by default, but you can change
// it as follows. Be sure to make this change for each audience.
if ( SUCCEEDED( hr ) )
{
hr = pAudnc->put_VideoCodec(0, 2);
}
// Make the video output size match the input size by setting height and width to 0.
if ( SUCCEEDED( hr ) )
{
hr = pAudnc->put_VideoHeight(0, 0);
}
if ( SUCCEEDED( hr ) )
{
hr = pAudnc->put_VideoWidth(0, 0);
}
// Change the buffer size to 5 seconds. By default, the end user's default setting is used.
if ( SUCCEEDED( hr ) )
{
hr = pAudnc->put_VideoBufferSize(0, 5000);
}
}
// Change the video image sharpness for the first audience only.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->get_Audience(0, &pAudnc);
}
if ( SUCCEEDED( hr ) )
{
hr = pAudnc->put_VideoImageSharpness(0, 70);
}
// Validate the settings to make sure the profile has no errors.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->Validate();
}
// Save the profile to a .prx file.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->SaveToFile(CComBSTR("C:\\Program Files\\Windows Media Components\\Encoder\\Profiles\\CPPprofile.prx"));
}
// Release pointers.
if ( pAudnc )
{
pAudnc->Release();
pAudnc = NULL;
}
if ( pPro2 )
{
pPro2->Release();
pPro2 = NULL;
}
Requirements
Header: wmencode.h
Library: wmenc.exe
See Also
.gif)