共用方式為


啟動 BDA Minidriver

當 BDA 裝置開始運作時,隨插即用 (PnP) 管理員會分派IRP_MN_START_DEVICE。 AVStream 類別接著會呼叫與 BDA 裝置相關聯的 BDA 迷你驅動程式的開始常式。 此開始常式會從登錄擷取裝置的相關資訊、設定裝置的相關資訊,然後呼叫 BdaCreateFilterFactory 支援函式以:

  • 從裝置的初始篩選描述項 (建立裝置的篩選處理站 KSFILTER_DESCRIPTOR) 。 初始篩選描述項會參考篩選和輸入針腳的分派和自動化資料表。 如需詳細資訊,請參閱 建立分派資料表定義自動化資料表

  • 將篩選處理站與 BDA_FILTER_TEMPLATE 結構產生關聯。 此結構會參考裝置的範本篩選描述項,以及可能配對的輸入和輸出針腳清單。 此描述項和清單會接著參考:

    • 網路提供者可用來判斷 BDA 篩選器拓撲的靜態範本結構。
    • BDA 篩選的節點和釘選,以及連接篩選的可能方式。
    • 網路提供者可用來建立和關閉篩選實例的常式。
    • 網路提供者可用來操作 BDA 篩選的靜態範本結構。
  • 向 BDA 支援程式庫註冊BDA_FILTER_TEMPLATE指定的靜態範本結構,讓程式庫可以為 BDA 迷你驅動程式的屬性和方法提供預設處理。

下列程式碼片段顯示 BdaCreateFilterFactory 設定為篩選處理站之裝置的初始篩選描述元範例:

const KSFILTER_DESCRIPTOR    InitialTunerFilterDescriptor;
//
//  Filter Factory Descriptor for the tuner filter
//
//  This structure brings together all of the structures that define
//  the tuner filter instance as it appears when it is first created.
//  Note that not all template pin and node types are exposed as
//  pin and node factories when the filter instance is created.
//
DEFINE_KSFILTER_DESCRIPTOR(InitialTunerFilterDescriptor)
{
    &FilterDispatch,             // Table of dispatch routines
    &FilterAutomation,           // Table of properties and methods
    KSFILTER_DESCRIPTOR_VERSION, // Version
    0,                           // Flags
    &KSNAME_Filter,              // Reference Guid
    DEFINE_KSFILTER_PIN_DESCRIPTORS(InitialPinDescriptors),
                                   // PinDescriptorsCount
                                   // PinDescriptorSize
                                   // PinDescriptors
    DEFINE_KSFILTER_CATEGORY(KSCATEGORY_BDA_RECEIVER_COMPONENT),
                            // CategoriesCount
                            // Categories
    DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL(NodeDescriptors),
                                    // NodeDescriptorsCount
                                    // NodeDescriptorSize
                                    // NodeDescriptors
    DEFINE_KSFILTER_DEFAULT_CONNECTIONS, // ConnectionsCount
                                         // Connections
    NULL                // ComponentId
};

下列程式碼片段顯示初始化篩選所公開之初始針腳描述元陣列的範例。 在網路提供者設定該篩選之前,網路提供者會先使用這類陣列來初始化篩選。 不過,在設定初始化篩選時,網路提供者會選取BDA_FILTER_TEMPLATE結構之篩選描述元成員指標中所參考的針腳。 如需詳細資訊 ,請參閱設定 BDA 篩選

//
//  Initial Pin Descriptors
//
//  This data structure defines the pins that will appear on the 
//  filter when it is first created.
//
const
KSPIN_DESCRIPTOR_EX
InitialPinDescriptors[] =
{
    //  Antenna Pin
    //
    {
        &AntennaPinDispatch,
        &AntennaAutomation,   // AntennaPinAutomation
        {
            0,  // Interfaces
            NULL,
            0,  // Mediums
            NULL,
            SIZEOF_ARRAY(AntennaPinRanges),
            AntennaPinRanges,
            KSPIN_DATAFLOW_IN,
            KSPIN_COMMUNICATION_BOTH,
            NULL,   // Name
            NULL,   // Category
            0
        },
        KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT | 
        KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING | 
        KSPIN_FLAG_FIXED_FORMAT,
        1,      // InstancesPossible
        0,      // InstancesNecessary
        NULL,   // Allocator Framing
        NULL    // PinIntersectHandler
    }
};

請注意,初始化的篩選準則必須公開一或多個輸入針腳,讓 Microsoft DirectShow IFilterMapper2IFilterMapper 介面可以找到該篩選準則。 如需這些 DirectShow 介面的相關資訊,請參閱Microsoft Windows SDK檔。

下列程式碼片段顯示BDA_FILTER_TEMPLATE結構和相關結構和陣列的範例:

const KSFILTER_DESCRIPTOR  TemplateTunerFilterDescriptor;
const BDA_PIN_PAIRING  *TemplateTunerPinPairings;
//
//  BDA Template Topology Descriptor for the filter factory.
//
//  This structure defines the pin and node types that the network 
//  provider can create on the filter and how they are arranged. 
//
const
BDA_FILTER_TEMPLATE
TunerBdaFilterTemplate =
{
    &TemplateTunerFilterDescriptor,
    SIZEOF_ARRAY(TemplateTunerPinPairings),
    TemplateTunerPinPairings
};
//
//  Filter Factory Descriptor for the tuner filter template topology
//
//  This structure brings together all of the structures that define
//  the topologies that the tuner filter can assume as a result of
//  pin factory and topology creation methods.
//
DEFINE_KSFILTER_DESCRIPTOR(TemplateTunerFilterDescriptor)
{
    &FilterDispatch,             // Table of dispatch routines
    &FilterAutomation,           // Table of properties and methods
    KSFILTER_DESCRIPTOR_VERSION, // Version
    0,                           // Flags
    &KSNAME_Filter,              // Reference Guid
    DEFINE_KSFILTER_PIN_DESCRIPTORS(TemplatePinDescriptors),
                                   // PinDescriptorsCount
                                   // PinDescriptorSize
                                   // PinDescriptors
    DEFINE_KSFILTER_CATEGORY(KSCATEGORY_BDA_RECEIVER_COMPONENT),
                            // CategoriesCount
                            // Categories
    DEFINE_KSFILTER_NODE_DESCRIPTORS(NodeDescriptors),  
                                    // NodeDescriptorsCount
                                    // NodeDescriptorSize
                                    // NodeDescriptors
    DEFINE_KSFILTER_CONNECTIONS(TemplateTunerConnections),
                               // ConnectionsCount
                               // Connections
    NULL                // ComponentId
};
//
//  Lists how pairs of input and output pins are configured. 
//
//  Values given to the BDA_PIN_PAIRING structures in the list inform 
//  the network provider which nodes get duplicated when more than one 
//  output pin type is connected to a single input pin type or when
//  more that one input pin type is connected to a single output pin 
//  type. Also, informs of the joints array.
//
const
BDA_PIN_PAIRING TemplateTunerPinPairings[] =
{
    //  Antenna to Transport Topology Joints
    //
    {
        0,  // ulInputPin
        1,  // ulOutputPin
        1,  // ulcMaxInputsPerOutput
        1,  // ulcMinInputsPerOutput
        1,  // ulcMaxOutputsPerInput
        1,  // ulcMinOutputsPerInput
        SIZEOF_ARRAY(AntennaTransportJoints),   // ulcTopologyJoints
        AntennaTransportJoints                  // pTopologyJoints
    }
};