⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 完整的基于Conxant平台的USB电视棒的WIN驱动程序。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    &TVAudioReferenceGuid,                  // Reference GUID
    DEFINE_KSFILTER_PIN_DESCRIPTORS( TvAudioFilterPinDescriptors ),
    DEFINE_KSFILTER_CATEGORY( KSCATEGORY_TVAUDIO ),
    0,
    0,
    NULL,
    0,
    NULL,
    NULL                                    // Component ID
};

static
const KSFILTER_DESCRIPTOR*
const FilterDescriptors[] = 
{
    &g_audio_filter_descriptor
};


/////////////////////////////////////////////////////////////////////////////////////////
//***************************************************************************************
//TS Filter
//***************************************************************************************
/////////////////////////////////////////////////////////////////////////////////////////
const GUID CaptureTSFilterCategories[] = 
{
    STATICGUIDOF (KSCATEGORY_CAPTURE),
    STATICGUIDOF (KSCATEGORY_BDA_RECEIVER_COMPONENT)
}; 


KSPIN_MEDIUM g_ts_input_medium =
{
    TRANSPORT_PIN_MEDIUM, 0, 0
};

//////////////////////////////////////////////////////////////////////////////
//
// Description:
//  This item describes the connection topology of the digital capture
//  filter. It shows that the input is directly connected to the output.
//
//////////////////////////////////////////////////////////////////////////////
const KSTOPOLOGY_CONNECTION CaptureTSFilterConnections[] =
{
    { KSFILTER_NODE, 0, KSFILTER_NODE, 1 } //no nodes, directly connect input to output
};

//
// CaptureTSFilterPinDescriptors:
//
// The list of pin descriptors on the capture filter.  
//
KSPIN_DESCRIPTOR_EX CaptureTSFilterPinDescriptors[] = 
{
    //
    //Input TS Pin
    //
    {
        NULL,                                       // Pin dispatch
        NULL,                                       // Automation table
        {
            0,                                      // Interface Count 
            NULL,                                   // Interfaces
            1,                                      // Mediums Count 
            &g_ts_input_medium,                     // Mediums
            SIZEOF_ARRAY(g_bda_transport_pin_ranges),// Range Count
            g_bda_transport_pin_ranges,             // Ranges
            KSPIN_DATAFLOW_IN,                      // Dataflow
            KSPIN_COMMUNICATION_BOTH,               // Communication (both source and sink)
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Category 
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Name
            0                                       // Reserved
        },
        
        KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT | 
        KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING | 
        KSPIN_FLAG_FIXED_FORMAT,                    //Pin flags
        1,                                          // Instances Possible
        0,                                          // Instances Necessary
        NULL,                                       // Allocator Framing
        BdaTransportPin_IntersectRange
    },

    //TS output pin
    {
        &g_ts_pin_dispatch,
        NULL,             
        {
            NULL,                                   // Interfaces (NULL, 0 == default)
            0,
            NULL,                                   // Mediums (NULL, 0 == default)
            0,

            SIZEOF_ARRAY(g_ts_pin_data_ranges),     // Range Count
            g_ts_pin_data_ranges,                   // Ranges
            
            KSPIN_DATAFLOW_OUT,                     // Dataflow
            KSPIN_COMMUNICATION_BOTH,               // Communication (both source and sink)
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Category
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Name
            0                                       // Reserved
        },

		KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING |
        KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,		// Pin flags
        1,                                          // Instances Possible
        0,                                          // Instances Necessary
        &PIN_ALLOCATOR_FRAMING,                     // Allocator Framing
        (PFNKSINTERSECTHANDLEREX)TS_Pin::static_IntersectHandler
    }
};

//
// Capture2TSFilterPinDescriptors:
//
// The list of pin descriptors on the capture filter.  
// DVT board need to support 2 TS
KSPIN_DESCRIPTOR_EX Capture2TSFilterPinDescriptors[] = 
{
    //
    //Input TS Pin
    //
    {
        NULL,                                       // Pin dispatch
        NULL,                                       // Automation table
        {
            0,                                      // Interface Count 
            NULL,                                   // Interfaces
            1,                                      // Mediums Count 
            &g_ts_input_medium,                     // Mediums
            SIZEOF_ARRAY(g_bda_transport_pin_ranges),// Range Count
            g_bda_transport_pin_ranges,             // Ranges
            KSPIN_DATAFLOW_IN,                      // Dataflow
            KSPIN_COMMUNICATION_BOTH,               // Communication (both source and sink)
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Category 
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Name
            0                                       // Reserved
        },
        
        KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT | 
        KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING | 
        KSPIN_FLAG_FIXED_FORMAT,                    //Pin flags
        1,                                          // Instances Possible
        0,                                          // Instances Necessary
        NULL,                                       // Allocator Framing
        BdaTransportPin_IntersectRange
    },

    //TS output pin
    {
        &g_ts_pin_dispatch,
        NULL,             
        {
            NULL,                                   // Interfaces (NULL, 0 == default)
            0,
            NULL,                                   // Mediums (NULL, 0 == default)
            0,

            SIZEOF_ARRAY(g_ts_pin_data_ranges),     // Range Count
            g_ts_pin_data_ranges,                   // Ranges
            
            KSPIN_DATAFLOW_OUT,                     // Dataflow
            KSPIN_COMMUNICATION_BOTH,               // Communication (both source and sink)
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Category
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Name
            0                                       // Reserved
        },

		KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING |
        KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,		// Pin flags
        1,                                          // Instances Possible
        0,                                          // Instances Necessary
        &PIN_ALLOCATOR_FRAMING,                     // Allocator Framing
        (PFNKSINTERSECTHANDLEREX)TS_Pin::static_IntersectHandler
    },

    //TS2 output pin
    {
        &g_ts2_pin_dispatch,
        NULL,             
        {
            NULL,                                   // Interfaces (NULL, 0 == default)
            0,
            NULL,                                   // Mediums (NULL, 0 == default)
            0,

            SIZEOF_ARRAY(g_ts_pin_data_ranges),     // Range Count
            g_ts_pin_data_ranges,                   // Ranges
            
            KSPIN_DATAFLOW_OUT,                     // Dataflow
            KSPIN_COMMUNICATION_BOTH,               // Communication (both source and sink)
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Category
            (GUID *) &PINNAME_BDA_TRANSPORT,        // Name
            0                                       // Reserved
        },

		KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING |
        KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,		// Pin flags
        1,                                          // Instances Possible
        0,                                          // Instances Necessary
        &PIN_ALLOCATOR_FRAMING,                     // Allocator Framing
        (PFNKSINTERSECTHANDLEREX)TS_Pin::static_IntersectHandler
    }
};


//
// CaptureTSFilterDescriptor:
//
// The descriptor for the capture filter.  We don't specify any topology
// since there's only one pin on the filter.  Realistically, there would
// be some topological relationships here because there would be input 
// pins from crossbars and the like.
//

KSFILTER_DESCRIPTOR CaptureTSFilterDescriptor=
{
    &TsCaptureFilterDispatch,                                           // Dispatch Table
    NULL,                                                               // Automation Table
    KSFILTER_DESCRIPTOR_VERSION,                                        // Version
    0,                                                                  // Flags
    &GUID_TSCaptureFilter,                                              // Reference GUID
    DEFINE_KSFILTER_PIN_DESCRIPTORS (CaptureTSFilterPinDescriptors),    // PinDescriptors
    DEFINE_KSFILTER_CATEGORY(KSCATEGORY_BDA_RECEIVER_COMPONENT),        // Categories
    DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL,                              // NodeDescriptors
    DEFINE_KSFILTER_CONNECTIONS(CaptureTSFilterConnections),            // Connections
    NULL                                    // Component ID
};

//
// Capture2TSFilterDescriptor:
//
// The descriptor for the capture filter.  We don't specify any topology
// since there's only one pin on the filter.  Realistically, there would
// be some topological relationships here because there would be input 
// pins from crossbars and the like.
//

KSFILTER_DESCRIPTOR Capture2TSFilterDescriptor=
{
    &TsCaptureFilterDispatch,                                           // Dispatch Table
    NULL,                                                               // Automation Table
    KSFILTER_DESCRIPTOR_VERSION,                                        // Version
    0,                                                                  // Flags
    &GUID_TSCaptureFilter,                                              // Reference GUID
    DEFINE_KSFILTER_PIN_DESCRIPTORS (Capture2TSFilterPinDescriptors),    // PinDescriptors
    DEFINE_KSFILTER_CATEGORY(KSCATEGORY_BDA_RECEIVER_COMPONENT),        // Categories
    DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL,                              // NodeDescriptors
    DEFINE_KSFILTER_CONNECTIONS(CaptureTSFilterConnections),            // Connections
    NULL                                    // Component ID
};

// CaptureDeviceDescriptor:
//
// This is the device descriptor for the capture device.  It points to the
// dispatch table and contains a list of filter descriptors that describe
// filter-types that this device supports.  Note that the filter-descriptors
// can be created dynamically and the factories created via
// KsCreateFilterFactory as well.
static
const
KSDEVICE_DESCRIPTOR
CaptureDeviceDescriptor = 
{
    &CaptureDeviceDispatch,
    SIZEOF_ARRAY( FilterDescriptors ),
    FilterDescriptors,
    KSDEVICE_DESCRIPTOR_VERSION
};


/*++ ********************************************************************\
*
*   Routine Description:
*
*       _purecall stub necessary for virtual function
*       usage in drivers on 98 gold
*
*   Arguments:
*
*       None
*
*   Return Value:
*
*       0
*
*   History:
*
*       00-00-0000 -by- Tom Zakrajsek [tomz]
*       Initial Revision.
*
\******************************************************************** --*/

extern "C"
int __cdecl
_purecall(
    void
    )
{
    return 0;
}


extern "C"
NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING RegistryPath
    )
{
    NTSTATUS retval = STATUS_SUCCESS;

    DbgTracer t( __FUNCTION__ );

    // Simply pass the device descriptor and parameters off to AVStream
    // to initialize us.  This will cause filter factories to be set up
    // at add & start.  Everything is done based on the descriptors passed
    // here.
    retval =  KsInitializeDriver( DriverObject,
                               RegistryPath,
                               &CaptureDeviceDescriptor );

    DbgLogInfo(("KsInitializeDriver returned= %08x\n", retval));
    return retval;
}



#if DBG
    // declare as private to disallow default constructor
    DbgTracer::DbgTracer()
    {
    }

    DbgTracer::DbgTracer(char *scope_name)
    {
        strncpy(_name, scope_name, sizeof(_name)-1);
        _name[sizeof(_name)-1] = 0;
        DbgLogTrace(("Entering %s", _name));
    }

    DbgTracer::~DbgTracer()
    {
        DbgLogTrace(("Exiting %s", _name));
    }
#else
    DbgTracer::DbgTracer(){}
    DbgTracer::DbgTracer(char *scope_name){};
    DbgTracer::~DbgTracer(){};
#endif



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -