WinCE6.0 Camera驱动源码分析(一)

来源:互联网 发布:国内域名大全 编辑:程序博客网 时间:2024/04/24 18:28

http://jazka.blog.51cto.com/809003/717967

 

学习WinCE6.0下面的Camera也一段时间了,准备做些记录结束了。由于Camera驱动中有太多的数据结构、层次结构,而且依靠DirectShow架构,所以这里没法细节到代码,只能从整体上分析源码了。

      应用层操作Camera设备的接口主要就是IOCONTROL,今天先来看看CameraPin的各种IO控制码。
      本人使用的环境是WinCE6.0+Android6410开发板。
 
      一、CAM_IOControl函数,主要源码如下:
 
 
 
 
 
 
 
 
 
 
 
      1从上面的代码可以看出,每次都会调用AdapterHandleCustomRequests函数,该函数实际是个空函数,只有打印输出,没有实际的操作(也许是为了以后扩展用)。调用关系为:
AdapterHandleCustomRequestsàPDD_HandleAdapterCustomPropertiesà
HandleAdapterCustomPropertiesà打印输出
      2185行的AdapterHandlePinRequests函数,从名称可以看出是用来处理各种Pin的请求,即获取Pin的相关信息。
typedef enum {
    CSPROPERTY_PIN_CINSTANCES = 0,
    CSPROPERTY_PIN_CTYPES,
    CSPROPERTY_PIN_DATARANGES,
    CSPROPERTY_PIN_DATAINTERSECTION,
    CSPROPERTY_PIN_CATEGORY,
    CSPROPERTY_PIN_NAME,
} CSPROPERTY_PIN;
CSPROPERTY_PIN_CINSTANCES
Used to query for the current number of pins this pin factory has instantiated, as well as the maximum number of pins this pin factory can instantiate, per filter.
CSPROPERTY_PIN_CTYPES
Used to query the camera driver for the number of pin types it supports.
CSPROPERTY_PIN_DATARANGES
Used to determine the data ranges supported by pins instantiated by the pin factory.
CSPROPERTY_PIN_DATAINTERSECTION
Used to find a data format supported by pins instantiated by the pin factory. The client supplies a list of data formats; the CS filter returns the first data format on the list that is supported.
CSPROPERTY_PIN_CATEGORY
Used to query the camera driver for a pin's type (preview, capture, or still).
CSPROPERTY_PIN_DEVICENAME
Used to query the camera driver for a pin's name. Drivers can assign any name to a pin, but typically the name will be PIN1:.
CSPROPERTY_PIN_NAME
查询Pin的类型名称,如"Capture""Still""Preview"
      3189行的AdapterHandleVersion函数用来获得MDD/PDD接口的版本号。
      4193行的AdapterHandleVidProcAmpRequests函数用来获得或者设置基于过滤器的PCSPROPERTY_VIDEOPROCAMP_S属性。
CSPROPERTY_TYPE_GET
Retrieves the value of the specified property item.
CSPROPERTY_TYPE_SET
Sets the value of the specified property item.
CSPROPERTY_TYPE_BASICSUPPORT
Queries the request types that the driver handles for this property item. Returns CSPROPERTY_TYPE_GET or CSPROPERTY_TYPE_SET or both. All property sets must support this flag.
CSPROPERTY_TYPE_DEFAULTVALUES
Queries the default values for the specified property item.
      5197行的AdapterHandleCamControlRequests函数和上面的很类似,只是该函数获取或设置的属性为CSPROPERTY_CAMERACONTROL_S
      6201行的AdapterHandleVideoControlRequests函数用来处理视频控制的属性,主要包括两部分:
PCSPROPERTY_VIDEOCONTROL_CAPS_S
This structure is used to set or get filter-based properties in the PROPSETID_VIDCAP_VIDEOCONTROL property set. It describes the video-control capabilities of a minidriver, such as image flipping, or event triggering abilities.
PCSPROPERTY_VIDEOCONTROL_MODE_S
This structure describes video-control modes for a stream, such as image flipping or event triggering abilities.
      7205行的AdapterHandleDroppedFramesRequests函数主要处理丢失的帧信息。
PCSPROPERTY_DROPPEDFRAMES_CURRENT_S
This structure describes the dropped frame information from the minidriver.
 
      二、PIN_IOControl函数,主要是关于视频流数据的操作接口,源码如下:
 
 
      1IOCTL_CS_PROPERTY处理与属性相关的请求,主要调用PinHandleCustomRequests函数和PinHandleConnectionRequests函数。PinHandleCustomRequests调用关系为:PDDHandlePinCustomPropertiesàCCameraPdd::HandleSensorModeCustomProperties。上述调用都是空函数,除了打印输出以外,没有其他的操作。
      PinHandleConnectionRequests函数是比较重要的,用来描述Pin的连接关系,根据请求的不同分以下几种:
typedef enum {
    CSPROPERTY_CONNECTION_STATE,
    CSPROPERTY_CONNECTION_DATAFORMAT,
    CSPROPERTY_CONNECTION_ALLOCATORFRAMING,
    CSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,
    CSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX
} CSPROPERTY_CONNECTION;
CSPROPERTY_CONNECTION_STATE
Sets the current run state of the pin. This property returns a value from the CSSTATE enumeration.
The pin only reads or writes data in the CSSTATE_RUN state. Both individual pins and the CS filter as a whole may support this property.
CSPROPERTY_CONNECTION_DATAFORMAT
Used to get or set the current data format.
This property returns a CSDATAFORMAT specifying the current data format.
CS filters only need to support this property if they allow clients to reset the current property, or if connections can be made with the data format incompletely specified.
CSPROPERTY_CONNECTION_ALLOCATORFRAMING
Used to determine framing requirements for a pin.
This property returns a CSALLOCATOR_FRAMING structure, which describes the framing requirements for the pin. For example, the FrameSize member specifies the frame size of data on the pin.
CSPROPERTY_CONNECTION_PROPOSEDATAFORMAT
Used to propose a new data format for the connection.
This property returns a CSDATAFORMAT specifying the proposed data format.
The CS filter returns STATUS_SUCCESS if the pin can be reset to the proposed data format, or an error code otherwise. Note that this property request does not change the data format. Clients use CSPROPERTY_CONNECTION_DATAFORMAT to change the format.
      2IOCTL_CS_BUFFERS处理与图像数据存储相关的请求,包括buffer有驱动分配还是用户分配、在驱动和DShow之间传递数据等,主要调用PinHandleBufferRequest函数,根据Buffer管理的命令不同,分以下几种:
typedef enum {
        CS_ALLOCATE,
        CS_ENQUEUE,
        CS_DEALLOCATE
} BUFFER_COMMANDS;
CS_ALLOCATE
Indicates that the driver should allocate the buffer.
CS_ENQUEUE
Indicates that the driver should add a buffer to its queue.
CS_DEALLOCATE
Indicates that the driver should free the memory for the buffer.
       3IOCTL_STREAM_INSTANTIATE处理流的实例化操作,主要调用StreamInstantiate函数。
原创粉丝点击