共用方式為


擷取篩選的釘選需求

[與此頁面相關聯的功能,DirectShow是舊版功能。 它已被 MediaPlayer、imfMediaEngine 取代,並在媒體基金會 音訊/視訊擷取。 這些功能已針對 Windows 10 和 Windows 11 進行優化。 Microsoft強烈建議新程式代碼盡可能在媒體 基礎中使用 MediaPlayerIMFMediaEngine 音訊/視訊擷取,而不是 DirectShow。 Microsoft建議使用舊版 API 的現有程式代碼,盡可能改寫成使用新的 API。]

本主題描述在 DirectShow 擷取篩選上實作輸出釘選的需求。

釘選名稱

您可以指定任何名稱的釘選。 如果釘選名稱開頭為 tilde (~) 字元,則當應用程式呼叫 IGraphBuilder::RenderFile時,Filter Graph 管理員不會自動轉譯該釘選。 例如,如果篩選有擷取釘選和預覽釘選,您可以分別將其命名為 “~Capture” 和 “Preview”。 如果應用程式在圖形中轉譯該篩選,預覽釘選會連線到其預設轉譯器,且沒有任何專案會連線到擷取釘選,這是合理的默認行為。 這也適用於傳遞不是要轉譯之參考數據的釘選,或需要設定自定義屬性的釘選。 請注意,具有Tilde (~) 前置詞的針腳仍可由應用程式手動連接。

釘選類別

擷取篩選一律有擷取釘選,而且可能有預覽釘選。 某些擷取篩選可能會有其他輸出釘選,以提供其他類型的數據,例如控制資訊。 每個輸出針腳都必須公開 IKsPropertySet 介面。 應用程式會使用此介面來判斷針腳類別。 針腳通常會傳回PIN_CATEGORY_CAPTURE或PIN_CATEGORY_PREVIEW。 如需詳細資訊,請參閱 Pin 屬性集

下列範例示範如何實作 IKsPropertySet,以傳回擷取釘選上的釘選類別:

// Set: Cannot set any properties.
HRESULT CMyCapturePin::Set(REFGUID guidPropSet, DWORD dwID,
    void *pInstanceData, DWORD cbInstanceData, void *pPropData, 
    DWORD cbPropData)
{
    return E_NOTIMPL;
}

// Get: Return the pin category (our only property). 
HRESULT CMyCapturePin::Get(
    REFGUID guidPropSet,   // Which property set.
    DWORD dwPropID,        // Which property in that set.
    void *pInstanceData,   // Instance data (ignore).
    DWORD cbInstanceData,  // Size of the instance data (ignore).
    void *pPropData,       // Buffer to receive the property data.
    DWORD cbPropData,      // Size of the buffer.
    DWORD *pcbReturned     // Return the size of the property.
)
{
    if (guidPropSet != AMPROPSETID_Pin) 
        return E_PROP_SET_UNSUPPORTED;
    if (dwPropID != AMPROPERTY_PIN_CATEGORY)
        return E_PROP_ID_UNSUPPORTED;
    if (pPropData == NULL && pcbReturned == NULL)
        return E_POINTER;
    if (pcbReturned)
        *pcbReturned = sizeof(GUID);
    if (pPropData == NULL)  // Caller just wants to know the size.
        return S_OK;
    if (cbPropData < sizeof(GUID)) // The buffer is too small.
        return E_UNEXPECTED;
    *(GUID *)pPropData = PIN_CATEGORY_CAPTURE;
    return S_OK;
}

// QuerySupported: Query whether the pin supports the specified property.
HRESULT CMyCapturePin::QuerySupported(REFGUID guidPropSet, DWORD dwPropID,
    DWORD *pTypeSupport)
{
    if (guidPropSet != AMPROPSETID_Pin)
        return E_PROP_SET_UNSUPPORTED;
    if (dwPropID != AMPROPERTY_PIN_CATEGORY)
        return E_PROP_ID_UNSUPPORTED;
    if (pTypeSupport)
        // We support getting this property, but not setting it.
        *pTypeSupport = KSPROPERTY_SUPPORT_GET; 
    return S_OK;
}

寫入擷取篩選