Méthode IWMDMDevice3 ::GetFormatCapability (mswmdm.h)

La méthode GetFormatCapability récupère la prise en charge des appareils pour les fichiers d’un format spécifié. Les fonctionnalités sont exprimées en tant que propriétés prises en charge et leurs valeurs autorisées.

Syntaxe

HRESULT GetFormatCapability(
  [in]  WMDM_FORMATCODE        format,
  [out] WMDM_FORMAT_CAPABILITY *pFormatSupport
);

Paramètres

[in] format

Valeur de l’énumération WMDM_FORMATCODE représentant le format interrogé.

[out] pFormatSupport

Pointeur vers la structure WMDM_FORMAT_CAPABILITY retournée contenant les propriétés prises en charge et leurs valeurs autorisées. Ces valeurs doivent être publiées par l’application, comme décrit dans Obtention des fonctionnalités de format sur les appareils qui prennent en charge IWMDMDevice3.

Valeur retournée

Cette méthode retourne un code HRESULT. Toutes les méthodes d’interface dans Windows Media Gestionnaire de périphériques peuvent retourner l’une des classes suivantes de codes d’erreur :

  • Codes d’erreur COM standard
  • Codes d’erreur Windows convertis en valeurs HRESULT
  • Codes d’erreur Gestionnaire de périphériques Windows Media
Pour obtenir une liste complète des codes d’erreur possibles, consultez Codes d’erreur.

Remarques

Le client peut obtenir la liste des formats pris en charge à l’aide de la méthode IWMDMDevice3 ::GetProperty pour interroger la propriété d’appareil g_wszWMDMFormatsSupported .

Pour un format particulier, un client peut appeler cette fonction pour obtenir les propriétés prises en charge et obtenir des informations sur les configurations des propriétés prises en charge (par exemple, des combinaisons de débit binaire et de taux d’échantillonnage). Ces informations sont exprimées sous la forme d’une fonctionnalité de format.

Exemples

La fonction suivante reçoit un pointeur d’appareil et un code de format, et récupère les fonctionnalités de format de l’appareil pour ce format. La fonction utilise une fonction personnalisée pour effacer les valeurs récupérées. Cette fonction personnalisée est illustrée dans Obtention des fonctionnalités de format sur les appareils qui prennent en charge IWMDMDevice3.


// Each format configuration is described by a WMDM_FORMAT_CAPABILITY enum, and
// has a WMDM_FORMAT_CAPABILITY structure describing the device capabilities for that format.
//        Each WMDM_FORMAT_CAPABILITY structure has a WMDM_PROP_CONFIG structure listing configurations.
//            Each WMDM_PROP_CONFIG has a WMDM_PROP_DESC describing a specific format configuration.
//                Each WMDM_PROP_DESC holds specific values as a range, a set, or a flag meaning all values are accepted.
HRESULT myGetFormatCaps(WMDM_FORMATCODE formatCode, IWMDMDevice3* pDevice)
{
    HRESULT hr = S_OK;

    // Get a list of supported configurations for the format.
    WMDM_FORMAT_CAPABILITY formatCapList;
    hr = pDevice->GetFormatCapability(formatCode, &formatCapList);
    HANDLE_HR(hr, "Got a WMDM_FORMATCODE structure in GetCaps","Couldn't get a WMDM_FORMATCODE structure in GetCaps");

    // Print out the format name.
    // TODO: Display a banner for device formats.
    PrintWMDM_FORMATCODE(formatCode); // Custom function to print out the format code.
    

    // Loop through the configurations and examine each one.
    for(UINT iConfig = 0; iConfig < formatCapList.nPropConfig; iConfig++)
    {
        WMDM_PROP_CONFIG formatConfig = formatCapList.pConfigs[iConfig];

        // Preference level for this configuration (lower number means more preferred).
        // TODO: Display a banner for the preference-level output.

        // Loop through all properties for this configuration and get supported
        // values for the property. Values can be a single value, a range, 
        // or a list of enumerated values.
        for(UINT iDesc = 0; iDesc < formatConfig.nPropDesc; iDesc++)
        {
            WMDM_PROP_DESC propDesc = formatConfig.pPropDesc[iDesc];
            // TODO: Display the property name.

            // Three ways a value can be represented: any, a range, or a list.
            switch (propDesc.ValidValuesForm)
            {
                case WMDM_ENUM_PROP_VALID_VALUES_ANY:
                    // TODO: Display a message indicating that all values are valid.
                    break;
                case WMDM_ENUM_PROP_VALID_VALUES_RANGE:
                    {
                        // List these in the docs as the propvariants set.
                        WMDM_PROP_VALUES_RANGE rng = propDesc.ValidValues.ValidValuesRange;
                        // TODO: Display a banner for the values to follow
                        // TODO: Display the max value.
                        // TODO: Display the min value.
                        // TODO: Display the step value.
                    }
                    break;
                case WMDM_ENUM_PROP_VALID_VALUES_ENUM:
                    {
                        // TODO: Display a banner for the values to follow.
                        WMDM_PROP_VALUES_ENUM list = propDesc.ValidValues.EnumeratedValidValues;
                        PROPVARIANT pVal;
                        for(UINT iValue = 0; iValue < list.cEnumValues; iValue++)
                        {
                            pVal = list.pValues[iValue];
                            // TODO: Display the current value.
                            PropVariantClear(&pVal);
                            PropVariantInit(&pVal);
                        }
                    }

                    break;
                default:
                    HANDLE_HR(E_FAIL, "Undefined configuration type in GetCaps" << endl, "");
                    break;
            }
        }
    }
    // Now clear the memory used by WMDM_FORMAT_CAPABILITY.
    FreeFormatCapability(formatCapList);

e_Exit:
    return hr;
}

Configuration requise

Condition requise Valeur
Plateforme cible Windows
En-tête mswmdm.h
Bibliothèque Mssachlp.lib

Voir aussi

Découverte des fonctionnalités de format d’appareil

IWMDMDevice3, interface