Skip to content

Latest commit

 

History

History
288 lines (227 loc) · 8.3 KB

nf-mfidl-mftranscodegetaudiooutputavailabletypes.md

File metadata and controls

288 lines (227 loc) · 8.3 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:mfidl.MFTranscodeGetAudioOutputAvailableTypes
MFTranscodeGetAudioOutputAvailableTypes function (mfidl.h)
Gets a list of output formats from an audio encoder.
MFT_FIELDOFUSE_UNLOCK_Attribute
MFTranscodeGetAudioOutputAvailableTypes
MFTranscodeGetAudioOutputAvailableTypes function [Media Foundation]
MF_TRANSCODE_ENCODINGPROFILE
MF_TRANSCODE_QUALITYVSSPEED
mf.mftranscodegetaudiooutputavailabletypes
mfidl/MFTranscodeGetAudioOutputAvailableTypes
mf\mftranscodegetaudiooutputavailabletypes.htm
mf
8750eacb-7e6f-4c17-987b-f4baa4eea847
12/05/2018
MFT_FIELDOFUSE_UNLOCK_Attribute, MFTranscodeGetAudioOutputAvailableTypes, MFTranscodeGetAudioOutputAvailableTypes function [Media Foundation], MF_TRANSCODE_ENCODINGPROFILE, MF_TRANSCODE_QUALITYVSSPEED, mf.mftranscodegetaudiooutputavailabletypes, mfidl/MFTranscodeGetAudioOutputAvailableTypes
mfidl.h
Windows
Windows 7 [desktop apps only]
Windows Server 2008 R2 [desktop apps only]
Mf.lib
Mf.dll
Windows
19H1
MFTranscodeGetAudioOutputAvailableTypes
mfidl/MFTranscodeGetAudioOutputAvailableTypes
c++
APIRef
kbSyntax
DllExport
mf.dll
MFTranscodeGetAudioOutputAvailableTypes

MFTranscodeGetAudioOutputAvailableTypes function

-description

Gets a list of output formats from an audio encoder.

-parameters

-param guidSubType [in]

Specifies the subtype of the output media. The encoder uses this value as a filter when it is enumerating the available output types. For information about the audio subtypes, see Audio Subtype GUIDs.

-param dwMFTFlags [in]

Bitwise OR of zero or more flags from the _MFT_ENUM_FLAG enumeration.

-param pCodecConfig [in]

A pointer to the IMFAttributes interface of an attribute store. The attribute store specifies the encoder configuration settings. This parameter can be NULL. The attribute store can hold any of the following attributes.

Value Meaning
MFT_FIELDOFUSE_UNLOCK_Attribute
Set this attribute to unlock an encoder that has field-of-use descriptions.
MF_TRANSCODE_ENCODINGPROFILE
Specifies a device conformance profile for a Windows Media encoder.
MF_TRANSCODE_QUALITYVSSPEED
Sets the tradeoff between encoding quality and encoding speed.

-param ppAvailableTypes [out]

Receives a pointer to the IMFCollection interface of a collection object that contains a list of preferred audio media types. The collection contains IMFMediaType pointers. The caller must release the interface pointer.

-returns

The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK
The function call succeeded.
MF_E_TRANSCODE_NO_MATCHING_ENCODER
Failed to find an encoder that matches the specified configuration settings.

-remarks

This function assumes the encoder will be used in its default encoding mode, which is typically constant bit-rate (CBR) encoding. Therefore, the types returned by the function might not work with other modes, such as variable bit-rate (VBR) encoding.

Internally, this function works by calling MFTEnumEx to find a matching encoder, and then calling IMFTransform::GetOutputAvailableType to get the encoder's output types.

Examples

The following example creates a transcode profile for Windows Media Audio (WMA).

template <class Q>
HRESULT GetCollectionObject(IMFCollection *pCollection, DWORD index, Q **ppObj)
{
    IUnknown *pUnk;
    HRESULT hr = pCollection->GetElement(index, &pUnk);
    if (SUCCEEDED(hr))
    {
        hr = pUnk->QueryInterface(IID_PPV_ARGS(ppObj));
        pUnk->Release();
    }
    return hr;
}

HRESULT CreateTranscodeProfile(IMFTranscodeProfile **ppProfile)
{
    IMFTranscodeProfile *pProfile = NULL;     // Transcode profile.
    IMFCollection   *pAvailableTypes = NULL;  // List of audio media types.
    IMFMediaType    *pAudioType = NULL;       // Audio media type.
    IMFAttributes   *pAudioAttrs = NULL;      // Copy of the audio media type.
    IMFAttributes   *pContainer = NULL;       // Container attributes.

    DWORD dwMTCount = 0;
    
    // Create an empty transcode profile.
    HRESULT hr = MFCreateTranscodeProfile(&pProfile);
    if (FAILED(hr))
    {
        goto done;
    }

    // Get output media types for the Windows Media audio encoder.

    // Enumerate all codecs except for codecs with field-of-use restrictions.
    // Sort the results.

    DWORD dwFlags = 
        (MFT_ENUM_FLAG_ALL & (~MFT_ENUM_FLAG_FIELDOFUSE)) | 
        MFT_ENUM_FLAG_SORTANDFILTER;

    hr = MFTranscodeGetAudioOutputAvailableTypes(MFAudioFormat_WMAudioV9, 
        dwFlags, NULL, &pAvailableTypes);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pAvailableTypes->GetElementCount(&dwMTCount);
    if (FAILED(hr))
    {
        goto done;
    }
    if (dwMTCount == 0)
    {
        hr = E_FAIL;
        goto done;
    }

    // Get the first audio type in the collection and make a copy.
    hr = GetCollectionObject(pAvailableTypes, 0, &pAudioType);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = MFCreateAttributes(&pAudioAttrs, 0);       
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pAudioType->CopyAllItems(pAudioAttrs);
    if (FAILED(hr))
    {
        goto done;
    }

    // Set the audio attributes on the profile.
    hr = pProfile->SetAudioAttributes(pAudioAttrs);
    if (FAILED(hr))
    {
        goto done;
    }

    // Set the container attributes.
    hr = MFCreateAttributes(&pContainer, 1);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pContainer->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_ASF);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pProfile->SetContainerAttributes(pContainer);
    if (FAILED(hr))
    {
        goto done;
    }

    *ppProfile = pProfile;
    (*ppProfile)->AddRef();

done:
    SafeRelease(&pProfile);
    SafeRelease(&pAvailableTypes);
    SafeRelease(&pAudioType);
    SafeRelease(&pAudioAttrs);
    SafeRelease(&pContainer);
    return hr;
}

-see-also

IMFCollection::GetElement

MFCreateTranscodeProfile

Media Foundation Functions

Tutorial: Encoding a WMA File