In the previous post, we gave an overview of the WIA-WPD Compatibility Layer and how WIA Applications can register for WIA_EVENT_DEVICE_CONNECTED events.
In this post, we will cover a more advanced topic: customization for PTP and MTP devices. The WIA-WPD Compatibility Layer supports basic extensibility for custom WIA events and WIA properties. These events and properties were provided in the PTP WIA class driver that shipped with Windows XP.
Adding Custom PTP/MTP WIA Event Codes
To specify a list of supported PTP/MTP event codes the 'WiaEventCodes' entry should be provided.
The following example shows 3 custom event codes being reported.
HKR,,"WiaEventCodes",”0x0001,0x0002,0x0003”
For each event code specified in the 'WiaEventCodes' entry, a corresponding 'WiaEventCodeXXX' entry must exist that specifies the name of the event and the GUID to use when reporting the event to WIA applications. The entry should be constructed using the prefix ‘WiaEventCode + the event code specified in WiaEventCodes entry’. If the WiaEventCodeXXX entry is missing, the event will not be reported to WIA applications.
HKR,,"WiaEventCode0x0001”,”{20179E3D-139C-40D3-A0CA-962B33D67EE3},My Custom Event”HKR,,"WiaEventCode0x0002”,”{259A62CF-D8FE-44D0-A747-B14F54A02133},My Amazing Event”HKR,,"WiaEventCode0x0003”,”{639F80C6-94D1-48E2-9D8E-6D0F12237E48},My Super Event”
Adding Custom PTP/WIA Property Codes
To specify a list of supported PTP/MTP property codes the ‘WiaPropertyCodes’ entry should be provided. WIA properties will only appear on the root item. These properties are commonly used to control/program the device.
The following example shows 3 custom property codes being reported.
HKR,,"WiaPropertyCodes",”0x0001,0x0002,0x0003”
For each property code specified in the ‘WiaPropertyCodes’ entry, a corresponding ‘WiaPropertyCodeXXX’ entry must exist that specifies the name of the property and the WIA property code to use when reporting the property to WIA applications. The entry should be constructed using the prefix ‘WiaPropertyCode + the property code specified in WiaPropertyCodes entry’. If the WiaPropertyCodeXXX entry is missing, the event will not be reported to WIA applications.
HKR,,"WiaPropertyCode0x0001”,”My Custom Device Property”HKR,,"WiaPropertyCode0x0002”,”My Amazing Device Property”HKR,,"WiaPropertyCode0x0003”,”My Super Device Property”
Sending PTP Custom Commands through WIA
PTP extension commands can be sent to the vendor's driver using IWiaItemExtras::Escape. In Windows Vista, the WIA-WPD Compatibility Layer repackages PTP extension commands sent using this method into WPD MTP/PTP extension commands, which are dispatched to the WPD MTP class driver. This mechanism exists to support legacy WIA vendor applications that relied on custom PTP commands from Windows XP.
Sending MTP Custom Commands through WPD
WPD supports sending of custom MTP commands to the MTP driver using the IPortableDevice::SendCommand API. For a step-by-step description, visit DimeBy8's excellent post here.
WIA to WPD Content Type and Format Mapping
The following table maps WIA Item Types to the WPD_OBJECT_CONTENT_TYPE.
In addition to video and image content, the WIA-WPD Compatiliby Layer supports thumbnails and audio annotations for objects that have them. Any data objects that do not fall under these categories (e.g. music files) will not appear in WIA applications.
WPD Object
WPD Content Type
WIA Item
WIA Item Type
Device object
N/A
Root item
(WiaItemTypeFolder | WiaItemTypeDevice | WiaItemTypeRoot)
Folder object
WPD_CONTENT_TYPE_FOLDER
Folder Item
WiaItemTypeFolder
Functional Object
WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT
Image Object
WPD_CONTENT_TYPE_IMAGE
Image Item
(WiaItemTypeImage | WiaItemTypeFile | WiaItemTypeTransfer)
Video Object
WPD_CONTENT_TYPE_VIDEO
Video Item
(WiaItemTypeVideo | WiaItemTypeFile | WiaItemTypeTransfer)
Audio Object (used for annotations)
WPD_CONTENT_TYPE_AUDIO
Audio Item
(WiaItemTypeAudio | WiaItemTypeFile | WiaItemTypeTransfer)
Other objects
WPD_CONTENT_TYPE_XXXX
N/A (These are ignored)
The following table maps the WIA_IPA_Format property to the WPD_OBJECT_FORMAT property:
WIA_IPA_FORMAT
The formats will be mapped as follows:
WiaImgFmt_EXIF
WPD_OBJECT_FORMAT_EXIF
WiaImgFmt_JPEG
WPD_OBJECT_FORMAT_JFIF
WiaImgFmt_PNG
WPD_OBJECT_FORMAT_PNG
WiaImgFmt_GIF
WPD_OBJECT_FORMAT_GIF
WiaImgFmt_TIFF
WPD_OBJECT_FORMAT_TIFF
WiaAudFmt_WAV
WPD_OBJECT_FORMAT_WAVE
WiaAudFmt_MP3
WPD_OBJECT_FORMAT_MP3
WiaAudFmt_AIFF
WPD_OBJECT_FORMAT_AIFF
WiaAudFmt_WMA
WPD_OBJECT_FORMAT_WMA
WiaImgFmt_MPG
WPD_OBJECT_FORMAT_MPEG
WiaImgFmt_AVI
WPD_OBJECT_FORMAT_AVI
WiaImgFmt_ASF
WPD_OBJECT_FORMAT_ASF
Configuration of the WIA-WPD Compatibility Layer
The following section lists the customization options in the WIA-WPD Compatibility Layer that can be disabled/enabled by the device's INF [AddReg] section:
Report EXIF Image Format as JPG
Some WIA applications expect the EXIF image format to be reported as WiaImgFmt_JPG and not WiaImgFmt_EXIF. To "opt-in" for this functionality, vendors can add the following to your device's INF:
HKR,,"ReportJPGFormatForEXIF",0x10001,1
WIA Item Tree Behavior for DCF
If the WIA-WPD Compatibility layer encounters a storage that supports DCF, it will ‘shift’ the WIA item tree contents closer to the root item so items are easily found. This will reduce the number of folder levels an application or user will have to navigate to get to the image or video content stored on the device. This functionality can be disabled by adding the following to your device’s .INF [AddReg] section.
HKR,,"DisableDCFSpecialProcessing",0x10001,1
This posting is provided "AS IS" with no warranties, and confers no rights.