Share via


擷取篩選準則的釘選需求

[與此頁面相關的功能 DirectShow是舊版功能。 它已被 MediaPlayerIMFMediaEngineMedia Foundation 中的音訊/視訊擷取取代。 這些功能已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用 MediaPlayerIMFMediaEngine音訊/視訊擷取 ,而不是 DirectShow。 Microsoft 建議使用舊版 API 的現有程式碼盡可能重寫為使用新的 API。

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

接腳名稱

您可以為釘選提供任何名稱。 如果針腳名稱開頭為 tilde (~) 字元,則當應用程式呼叫 IGraphBuilder::RenderFile時,篩選圖形管理員不會自動轉譯該釘選。 例如,如果篩選有擷取釘選和預覽釘選,您可以分別將其命名為 「~Capture」 和 「Preview」。 如果應用程式在圖形中轉譯該篩選,預覽釘選會連線到其預設轉譯器,而且不會連線到擷取針腳,這是合理的預設行為。 這也適用于傳遞不打算轉譯之參考資料的釘選,或需要設定自訂屬性的釘選。 請注意,具有波浪線 (~) 前置詞的針腳仍然可以由應用程式手動連接。

釘選類別

擷取篩選一律有擷取釘選,而且可能有預覽釘選。 某些擷取篩選可能會有其他輸出針腳,以傳遞其他類型的資料,例如控制資訊。 每個輸出針腳都必須公開 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;
}

撰寫擷取篩選