Metodo IWMDMDevice3::GetFormatCapability (mswmdm.h)

Il metodo GetFormatCapability recupera il supporto del dispositivo per i file di un formato specificato. Le funzionalità vengono espresse come proprietà supportate e i relativi valori consentiti.

Sintassi

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

Parametri

[in] format

Valore dell'enumerazione WMDM_FORMATCODE che rappresenta il formato sottoposto a query.

[out] pFormatSupport

Puntatore alla struttura WMDM_FORMAT_CAPABILITY restituita contenente le proprietà supportate e i relativi valori consentiti. Questi valori devono essere rilasciati dall'applicazione come descritto in Getting Format Capabilities on Devices that support IWMDMDevice3 (Recupero delle funzionalità di formato nei dispositivi che supportano IWMDMDevice3).

Valore restituito

Il metodo restituisce un valore HRESULT. Tutti i metodi di interfaccia in Windows Media Gestione dispositivi possono restituire una delle classi di codici di errore seguenti:

  • Codici di errore COM standard
  • Codici di errore di Windows convertiti in valori HRESULT
  • Codici di errore di Windows Media Gestione dispositivi
Per un elenco completo dei codici di errore possibili, vedere Codici di errore.

Commenti

Il client può ottenere l'elenco dei formati supportati usando il metodo IWMDMDevice3::GetProperty per eseguire una query sulla proprietà del dispositivo g_wszWMDMFormatsSupported .

Per un formato specifico, un client può chiamare questa funzione per ottenere le proprietà supportate e ottenere informazioni sulle configurazioni delle proprietà supportate (ad esempio, combinazioni di velocità di bit e frequenza di campionamento). Queste informazioni vengono espresse come funzionalità di formato.

Esempio

La funzione seguente passa un puntatore del dispositivo e un codice di formato e recupera le funzionalità di formato del dispositivo per tale formato. La funzione usa una funzione personalizzata per cancellare i valori recuperati. Questa funzione personalizzata è illustrata in Getting Format Capabilities on Devices that Support IWMDMDevice3 (Recupero delle funzionalità di formato nei dispositivi che supportano 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;
}

Requisiti

Requisito Valore
Piattaforma di destinazione Windows
Intestazione mswmdm.h
Libreria Mssachlp.lib

Vedi anche

Individuazione delle funzionalità del formato del dispositivo

Interfaccia IWMDMDevice3