Avvio di un minidriver BDA
Quando un dispositivo BDA inizia a funzionare, il gestore Plug and Play (PnP) invia IRP_MN_START_DEVICE. La classe AVStream chiama la routine iniziale del minidriver BDA associato al dispositivo BDA. Questa routine di avvio recupera informazioni sul dispositivo dal Registro di sistema, imposta informazioni sul dispositivo e quindi chiama la funzione di supporto di BdaCreateFilterFactory a:
Creare la factory di filtro per il dispositivo dal descrittore di filtro iniziale (KSFILTER_DESCRIPTOR) per il dispositivo. Il descrittore di filtro iniziale fa riferimento a tabelle di invio e automazione per il filtro e i pin di input. Per altre informazioni, vedere Creazione di tabelle di invio e definizione delle tabelle di automazione .
Associare la factory di filtro a una struttura BDA_FILTER_TEMPLATE . Questa struttura fa riferimento al descrittore di filtro modello per il dispositivo e all'elenco di possibili coppie di pin di input e output. Questo descrittore ed elenco a sua volta fa riferimento:
- Strutture modello statiche che un provider di rete può usare per determinare la topologia di un filtro BDA.
- Nodi e pin per un filtro BDA insieme ai possibili modi per connettere il filtro.
- Routine che un provider di rete può usare per creare e chiudere un'istanza di filtro.
- Strutture modello statiche che un provider di rete può usare per modificare un filtro BDA.
Registrare le strutture del modello statiche specificate da BDA_FILTER_TEMPLATE con la libreria di supporto BDA in modo che la libreria possa fornire la gestione predefinita per le proprietà e i metodi di un minidriver BDA.
Il frammento di codice seguente mostra un esempio di descrittore di filtro iniziale per il dispositivo che BdaCreateFilterFactory imposta come filtro factory:
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
};
Il frammento di codice seguente mostra un esempio di matrice di descrittori di pin iniziali esposti da un filtro inizializzato. Il provider di rete inizializza un filtro usando tale matrice prima che il provider di rete configura tale filtro. Tuttavia, quando si configura un filtro inizializzato, il provider di rete seleziona i pin a cui si fa riferimento nel puntatore al membro descrittore del filtro della struttura BDA_FILTER_TEMPLATE. Per altre informazioni, vedere Configurazione di un filtro 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
}
};
Si noti che un filtro inizializzato deve avere uno o più pin di input esposti in modo che l'interfaccia Microsoft DirectShow IFilterMapper2 o IFilterMapper possa individuare tale filtro. Per informazioni su queste interfacce DirectShow, vedere la documentazione Microsoft Windows SDK.
Il frammento di codice seguente mostra esempi di una struttura di BDA_FILTER_TEMPLATE e strutture e matrici correlate:
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
}
};