Re: Need to add a pin property/Filter property page to my BDA driver
- From: Imti <imtiazfirst@xxxxxxxxx>
- Date: Sat, 1 Mar 2008 23:31:33 -0800 (PST)
On Mar 1, 11:40 am, Tim Roberts <t...@xxxxxxxxx> wrote:
Imti <imtiazfi...@xxxxxxxxx> wrote:First I want to thank for your prompt answer :)
I have to add a pin property page/ fitler property page to my BDA
Capture driver.
Do you mean you need to add custom pin and filter pages? Or do you just
need to enable some of the standard ones?
Yes I want to add a custom pin and filter property. For example :
setting/getting the video resolution & bitrate on the output pin.
I have added all necessary thing to the driver and
called ksinitializesriver in the DriverEntry. I tried adding a plug-in
also. However I was unsucessful in getting the filter property page.
Can someone help me in giving me the steps that I need to follow. Any
help would be appreciated.
This is all about the registry. Does your plugin set up the registry
correctly? The property pages go in CurrentControlSset\Control\MediaSets.
Is your driver exposing the property set that matches the plugin's
interface?
As far as plug-in is concerned, I think I have taken extreme steps to
ensure that the registry entry have been added/done properly. Please
suggest me few trivial things that I need to verify that the registry
are proper or not.
How do I verify that the driver is exposing the property set, can you
explain me that please.
--========================================================
Tim Roberts, t...@xxxxxxxxx
Providenza & Boekelheide, Inc.
common.h header file: contains the GUID which the driver and plug-in
use:
========================================================
#define STATIC_KSNAME_CaptureNodePropertySet\
0x3cf32f0e, 0x83fa, 0x417e, 0xb5, 0x21, 0x8, 0x50, 0x3e, 0x1a,
0xa1, 0xd5
DEFINE_GUIDSTRUCT("3cf32f0e-83fa-417e-B521-08503E1AA1D5",
KSNAME_CaptureNodePropertySet);
#define KSNAME_CaptureNodePropertySet
DEFINE_GUIDNAMED(KSNAME_CaptureNodePropertySet)
typedef enum
{
KSPROPERTY_CAPTURENODE_SETFREQ,
KSPROPERTY_CAPTURENODE_SETFILENAME,
KSPROPERTY_CAPTURENODE_SETVIDEO_RESOLUTION,
KSPROPERTY_CAPTURENODE_SETBITRATE,
} KSPROPERTY_CAPTURENODE;
=======================================
Below is the Plug-in code setting the registry:
=======================================
CFactoryTemplate g_Templates[] =
{
{
L_CRUSHER_KSPROXY_PROPPAGE_TEXT,
&__uuidof( CrusherKsProxyPage ),
CrusherProxyPluginPage::CreateInstance,
NULL,
NULL
},
{
L_CRUSHER_KSPROXY_INTHANDLER_TEXT,
&__uuidof( ICrusherKsproxyConfig ),
CrusherProxyPluginIFace::CreateInstance,
NULL,
NULL
}
};
int g_cTemplates = SIZEOF_ARRAY( g_Templates );
static HRESULT CreateRegKey( HKEY hParentKey, LPWSTR wszSubkey, HKEY*
phKey )
{
HRESULT hResult = S_OK;
LONG lResult = RegCreateKeyExW(
hParentKey,
wszSubkey,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
phKey,
NULL );
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
return hResult;
}
STDAPI DllRegisterServer()
{
HRESULT hResult = AMovieDllRegisterServer();
if( SUCCEEDED( hResult ) )
{
WCHAR wszKey[1024];
OLECHAR wszGUID[64] = { 0 };
HKEY hKey;
LONG lResult;
// Add property set to property page mapping
memset( wszKey, 0, sizeof( wszKey ) );
wcscpy( wszKey, L"System\\CurrentControlSet\\Control\\MediaSets
\\" );
StringFromGUID2( KSNAME_CaptureNodePropertySet, wszGUID,
SIZEOF_ARRAY( wszGUID ) );
wcsncat( wszKey, wszGUID, SIZEOF_ARRAY( wszKey )-
wcslen( wszKey )-1 );
wcsncat( wszKey, L"\\PropertyPages\\", SIZEOF_ARRAY( wszKey )-
wcslen( wszKey )-1 );
StringFromGUID2( __uuidof( CrusherKsProxyPage ), wszGUID,
SIZEOF_ARRAY( wszGUID ) );
wcsncat( wszKey, wszGUID, SIZEOF_ARRAY( wszKey )-
wcslen( wszKey )-1 );
hResult = CreateRegKey( HKEY_LOCAL_MACHINE, wszKey, &hKey );
if( SUCCEEDED( hResult ) )
{
lResult = RegSetValueExW(
hKey,
L"",
0,
REG_SZ,
reinterpret_cast< CONST BYTE*
( L_CRUSHER_KSPROXY_PROPPAGE_TEXT ),
sizeof( L_CRUSHER_KSPROXY_PROPPAGE_TEXT ) );
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
RegCloseKey( hKey );
}
// Add property set to interface handler mapping
memset( wszKey, 0, sizeof( wszKey ) );
wcscpy( wszKey, L"System\\CurrentControlSet\\Control\
\MediaInterfaces\\" );
StringFromGUID2( KSNAME_CaptureNodePropertySet, wszGUID,
SIZEOF_ARRAY( wszGUID ) );
wcsncat( wszKey, wszGUID, SIZEOF_ARRAY( wszKey )-
wcslen( wszKey )-1 );
hResult = CreateRegKey( HKEY_LOCAL_MACHINE, wszKey, &hKey );
if( SUCCEEDED( hResult ) )
{
lResult = RegSetValueExW(
hKey,
L"",
0,
REG_SZ,
reinterpret_cast< CONST BYTE*
( L_CRUSHER_KSPROXY_INTHANDLER_TEXT ),
sizeof( L_CRUSHER_KSPROXY_INTHANDLER_TEXT ) );
if( lResult == ERROR_SUCCESS )
{
IID iid = __uuidof( ICrusherKsproxyConfig );
lResult = RegSetValueExW(
hKey,
L"IID",
0,
REG_BINARY,
reinterpret_cast< CONST BYTE*
( &iid ),sizeof( iid ) );
}
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
RegCloseKey( hKey );
}
}
return hResult;
}
STDAPI DllUnregisterServer()
{
HRESULT hResult = AMovieDllUnregisterServer();
if( hResult == REGDB_E_CLASSNOTREG )
{
// We're already unregistered
hResult = S_OK;
}
WCHAR wszKey[1024], wszSubkey[1024];
OLECHAR wszGUID[64];
HKEY hKey, hSubkey;
LONG lResult;
// NT based systems would remove the key only if doesn't have any
subkeys
// Remove property set to property page mapping added to registry
during registration
memset( wszKey, 0, sizeof( wszKey ) );
wcscpy( wszKey, L"System\\CurrentControlSet\\Control\\MediaSets\
\" );
wcscpy( wszSubkey, wszKey );
StringFromGUID2(KSNAME_CaptureNodePropertySet, wszGUID,
sizeof( wszGUID ) );
wcsncat( wszSubkey, wszGUID, SIZEOF_ARRAY( wszSubkey )-
wcslen( wszSubkey )-1 );
hResult = CreateRegKey( HKEY_LOCAL_MACHINE, wszSubkey, &hKey );
if( SUCCEEDED( hResult ) )
{
hResult = CreateRegKey( hKey, L"PropertyPages", &hSubkey );
if( SUCCEEDED( hResult ) )
{
OLECHAR wszGUID[64];
StringFromGUID2( __uuidof( CrusherKsProxyPage ), wszGUID,
sizeof( wszGUID ) );
lResult = RegDeleteKeyW( hSubkey, wszGUID );
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
RegCloseKey( hSubkey );
}
if( SUCCEEDED( hResult ) )
{
lResult = RegDeleteKeyW( hKey, L"PropertyPages" );
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
}
RegCloseKey( hKey );
}
if( SUCCEEDED( hResult ) )
{
hResult = CreateRegKey( HKEY_LOCAL_MACHINE, wszKey, &hKey );
if( SUCCEEDED( hResult ) )
{
lResult = RegDeleteKeyW( hKey, wszGUID );
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
}
RegCloseKey( hKey );
}
// Remove property set to interface handler mapping added to
registry during registration
memset( wszKey, 0, sizeof( wszKey ) );
wcscpy( wszKey, L"System\\CurrentControlSet\\Control\
\MediaInterfaces\\" );
hResult = CreateRegKey( HKEY_LOCAL_MACHINE, wszKey, &hKey );
if( SUCCEEDED( hResult ) )
{
lResult = RegDeleteKeyW( hKey, wszGUID );
if( lResult != ERROR_SUCCESS )
hResult = HRESULT_FROM_WIN32( GetLastError() );
RegCloseKey( hKey );
}
return hResult;
}
=======================================
Below is the Driver code setting the registry:
=======================================
Device.cpp:
----------------
extern "C"
NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS Status = STATUS_SUCCESS;
Status = KsInitializeDriver (
DriverObject,
RegistryPath,
&CaptureDeviceDescriptor
);
DbgPrint("CaptureSample DriverEntry called!\n");
.......
.........
return Status;
}
.....................
....................
// The filter descriptor for the capture device.
DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) {
&CaptureFilterDescriptor
};
........................
.......................
const
KSDEVICE_DISPATCH
CaptureDeviceDispatch = {
CCaptureDevice::DispatchCreate, // PnP Add Device
CCaptureDevice::DispatchPnpStart, // PnP Start
NULL, // Post-Start
NULL, // Pnp Query Stop
NULL, // Pnp Cancel Stop
CCaptureDevice::DispatchPnpStop, // Pnp Stop
NULL, // Pnp Query Remove
NULL, // Pnp Cancel Remove
NULL, // Pnp Remove
NULL, // Pnp Query Capabilities
NULL, // Pnp Surprise Remove
NULL, // Query Power
NULL // Set Power
};
const
KSDEVICE_DESCRIPTOR
CaptureDeviceDescriptor = {
&CaptureDeviceDispatch,
SIZEOF_ARRAY (FilterDescriptors),
FilterDescriptors,
KSDEVICE_DESCRIPTOR_VERSION
};
Filter.cpp:
-------------------
NTSTATUS
CCaptureFilter::ProcessFrequencyFromTuner(
IN PIRP pIrp,
IN PKSPROPERTY_CAPNODE_FREQUENCY_S pRequest,
IN OUT PKSPROPERTY_CAPNODE_FREQUENCY_S pData
)
{
PAGED_CODE();
// Make sure that we received correct property request
if( !IsEqualGUID( KSNAME_CaptureNodePropertySet, pRequest-
Property.Set ) )return STATUS_NOT_IMPLEMENTED;
if( pRequest->Property.Id != KSPROPERTY_CAPTURENODE_SETFREQ )
return STATUS_INVALID_PARAMETER;
// Get the filter this property corresponds to
ASSERT(pIrp);
PKSFILTER pKsFilter = KsGetFilterFromIrp( pIrp );
if( pKsFilter == NULL )
return STATUS_INVALID_PARAMETER;
PKSDEVICE Device = KsFilterGetDevice(pKsFilter);
CCaptureDevice* pDevice = reinterpret_cast<CCaptureDevice
*>(Device->Context);
NTSTATUS ntStatus = STATUS_SUCCESS;
if( pRequest->Property.Flags & KSPROPERTY_TYPE_SET )
ntStatus = pDevice->SetFrequency( &pRequest->Frequency );
else
{
ULONG ulSize = IoGetCurrentIrpStackLocation( pIrp )-
Parameters.DeviceIoControl.OutputBufferLength;if( ulSize < sizeof( KSPROPERTY_CAPNODE_FREQUENCY_S ) )
ntStatus = STATUS_BUFFER_TOO_SMALL;
else
{
pRequest->Frequency = pDevice->Get_theFrequency();
pIrp->IoStatus.Information =
sizeof( KSPROPERTY_CAPNODE_FREQUENCY_S );
}
}
return ntStatus;
}
DEFINE_KSAUTOMATION_TABLE(SampleTunerNodeAutomation) {
DEFINE_KSAUTOMATION_PROPERTIES(SampleTunerNodePropertySets),
DEFINE_KSAUTOMATION_METHODS_NULL,
DEFINE_KSAUTOMATION_EVENTS_NULL
};
//
// CaptureFilterPinDescriptors:
//
// The list of pin descriptors on the capture filter.
//
const KSPIN_DESCRIPTOR_EX CaptureFilterPinDescriptors
[CAPTURE_FILTER_PIN_COUNT] = {
{
//
// Capture Output Pin
//
&CapturePinDispatch,
&SampleTunerNodeAutomation, //NULL,
{
NULL, // Interfaces (NULL, 0 == default)
0,
NULL, // Mediums (NULL, 0 == default)
0,
SIZEOF_ARRAY (CaptureOutPinDataRanges), // Range Count
CaptureOutPinDataRanges, // Ranges
KSPIN_DATAFLOW_OUT, // Dataflow
KSPIN_COMMUNICATION_BOTH, // Communication
NULL, // Category
NULL, // Name
0 // Reserved
},
#if !defined(_BUILD_SW_TUNER_ON_X64)
// KSPIN_FLAG_GENERATE_MAPPINGS | // Pin Flags
#endif
KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,
1, // Instances Possible
1, // Instances Necessary
&CapturePinAllocatorFraming, // Allocator Framing
NULL // Format Intersect Handler
}
};
//
// CaptureFilterDispatch:
//
// This is the dispatch table for the capture filter. It provides
notification
// of creation, closure, processing (for filter-centrics, not for the
capture
// filter), and resets (for filter-centrics, not for the capture
filter).
//
const
KSFILTER_DISPATCH
CaptureFilterDispatch = {
CCaptureFilter::DispatchCreate, // Filter Create
NULL, // Filter Close
NULL, // Filter Process
NULL // Filter Reset
};
//
// Define the name GUID for our digital capture filter.
//
// NOTE! You must use a different GUID for each type of filter that
// your driver exposes.
//
#define STATIC_KSNAME_BdaSWCaptureFilter\
074649feL, 0x2dd8, 0x4c12, 0x8a, 0x23, 0xbd, 0x82, 0x8b, 0xad,
0xff, 0xfa
DEFINE_GUIDSTRUCT("074649FE-2DD8-4C12-8A23-BD828BADFFFA",
KSNAME_BdaSWCaptureFilter);
#define KSNAME_BdaSWCaptureFilter
DEFINE_GUIDNAMED(KSNAME_BdaSWCaptureFilter)
// Must match the KSSTRING used in the installation INFs interface
sections
// AND must match the KSNAME GUID above.
//
#define KSSTRING_BdaSWCaptureFilter L"{074649FE-2DD8-4C12-8A23-
BD828BADFFFA}"
DEFINE_KSPROPERTY_TABLE(SampleCaptureNodeSetFrequencyProperties)
{
DEFINE_KSPROPERTY_ITEM
(
KSPROPERTY_CAPTURENODE_SETFREQ, // Property
CCaptureFilter::ProcessFrequencyFromTuner, // Get Handler
sizeof(KSPROPERTY_CAPNODE_FREQUENCY_S), // MinProperty
sizeof(KSPROPERTY_CAPNODE_FREQUENCY_S), // MinData
CCaptureFilter::ProcessFrequencyFromTuner, // Set Handler
NULL, // Values
0, // RelationsCount
NULL, // Relations
NULL, // SupportHandler
0 // SerializedSize
),
DEFINE_KSPROPERTY_ITEM
(
KSPROPERTY_CAPTURENODE_SETFILENAME, // Property
CCaptureFilter::ProcessFileName, // Get Handler
sizeof(KSPROPERTY_CAPNODE_FILENAME_S), // MinProperty
sizeof(KSPROPERTY_CAPNODE_FILENAME_S), // MinData
CCaptureFilter::ProcessFileName, // Set Handler
NULL, // Values
0, // RelationsCount
NULL, // Relations
NULL, // SupportHandler
0 // SerializedSize
),
DEFINE_KSPROPERTY_ITEM
(
KSPROPERTY_CAPTURENODE_SETVIDEO_RESOLUTION, // Property
CCaptureFilter::ProcessVideoResolution, // Get Handler
sizeof(KSPROPERTY_CAPNODE_VIDEO_RESOLUTION_S), // MinProperty
sizeof(KSPROPERTY_CAPNODE_VIDEO_RESOLUTION_S), // MinData
CCaptureFilter::ProcessVideoResolution, // Set Handler
NULL, // Values
0, // RelationsCount
NULL, // Relations
NULL, // SupportHandler
0 // SerializedSize
),
DEFINE_KSPROPERTY_ITEM
(
KSPROPERTY_CAPTURENODE_SETBITRATE, // Property
CCaptureFilter::ProcessBitRate, // Get Handler
sizeof(KSPROPERTY_CAPNODE_BITRATE_S), // MinProperty
sizeof(KSPROPERTY_CAPNODE_BITRATE_S), // MinData
CCaptureFilter::ProcessBitRate, // Set Handler
NULL, // Values
0, // RelationsCount
NULL, // Relations
NULL, // SupportHandler
0 // SerializedSize
)
};
DEFINE_KSPROPERTY_SET_TABLE(SampleCaptureNodePropertySets)
{
DEFINE_KSPROPERTY_SET
(
&KSNAME_CaptureNodePropertySet, // Property Set defined
elsewhere
SIZEOF_ARRAY(SampleCaptureNodeSetFrequencyProperties), //
Number of properties in the array
SampleCaptureNodeSetFrequencyProperties, // Property set
array
0, // FastIoCount
NULL // FastIoTable
),
};
DEFINE_KSAUTOMATION_TABLE(SampleCaptureNodeAutomation) {
DEFINE_KSAUTOMATION_PROPERTIES(SampleCaptureNodePropertySets),
DEFINE_KSAUTOMATION_METHODS_NULL,
DEFINE_KSAUTOMATION_EVENTS_NULL
};
//
// CaptureFilterDescription:
//
// The descriptor for the capture filter.
//
const
KSFILTER_DESCRIPTOR
CaptureFilterDescriptor = {
&CaptureFilterDispatch, // Dispatch Table
&SampleCaptureNodeAutomation, // Automation Table
KSFILTER_DESCRIPTOR_VERSION, // Version
0, // Flags
&KSNAME_BdaSWCaptureFilter, // Reference GUID
// Pin Descriptor Table
//
// PinDescriptorsCount; exposes all template pins
// PinDescriptorSize; size of each item
// PinDescriptors; table of pin descriptors
//
DEFINE_KSFILTER_PIN_DESCRIPTORS (CaptureFilterPinDescriptors),
// Category Table
//
// CategoriesCount; number of categories in the table
// Categories; table of categories
//
DEFINE_KSFILTER_CATEGORIES (CaptureFilterCategories),
// Node Descriptor Table
//
// NodeDescriptorsCount; exposes all template nodes
// NodeDescriptorSize; size of each item
// NodeDescriptors; table of node descriptors
//
0,
sizeof (KSNODE_DESCRIPTOR),
NULL,
// Filter connection table
//
// ConnectionsCount; number of connections in the table
// Connections; table of connections
//
DEFINE_KSFILTER_CONNECTIONS(FilterConnections),
NULL // Component ID
};
.
- Follow-Ups:
- Re: Need to add a pin property/Filter property page to my BDA driver
- From: Tim Roberts
- Re: Need to add a pin property/Filter property page to my BDA driver
- References:
- Re: Need to add a pin property/Filter property page to my BDA driver
- From: Tim Roberts
- Re: Need to add a pin property/Filter property page to my BDA driver
- Prev by Date: Cannot connect CTransformFilter to output pin
- Next by Date: Re: DivX dies when used with ASF Writer
- Previous by thread: Re: Need to add a pin property/Filter property page to my BDA driver
- Next by thread: Re: Need to add a pin property/Filter property page to my BDA driver
- Index(es):
Relevant Pages
|