AM3517 WINCE7 capturetest APP 获得摄像头设备信息

调试AM3517 wince7 camera driver的时候发现TI的CAMERA测试程序CaptureTest运行时打印出如下信息

PID:04C8012E TID:0482012E CaptureTest: Capabilities of capture driver --->
PID:04C8012E TID:0482012E CaptureTest:0 - (Video, UYVY, 720x480, 16 bpp, 30 fps, 165.888 mbps)
PID:04C8012E TID:0482012E CaptureTest:1 - (Video, UYVY, 704x480, 16 bpp, 30 fps, 162.201 mbps)
PID:04C8012E TID:0482012E CaptureTest:2 - (Video, UYVY, 352x240, 16 bpp, 30 fps, 40.550 mbps)
PID:04C8012E TID:0482012E CaptureTest:3 - (Video, UYVY, 176x120, 16 bpp, 30 fps, 10.137 mbps)
PID:04C8012E TID:0482012E CaptureTest:4 - (Video, YUY2, 720x480, 16 bpp, 30 fps, 165.888 mbps)
PID:04C8012E TID:0482012E CaptureTest:5 - (Video, YUY2, 704x480, 16 bpp, 30 fps, 162.201 mbps)
PID:04C8012E TID:0482012E CaptureTest:6 - (Video, YUY2, 352x240, 16 bpp, 30 fps, 40.550 mbps)
PID:04C8012E TID:0482012E CaptureTest:7 - (Video, YUY2, 176x120, 16 bpp, 30 fps, 10.137 mbps)
PID:04C8012E TID:0482012E CaptureTest:8 - (Video, UYVY, 720x576, 16 bpp, 25 fps, 165.888 mbps)
PID:04C8012E TID:0482012E CaptureTest:9 - (Video, UYVY, 704x576, 16 bpp, 25 fps, 162.201 mbps)
PID:04C8012E TID:0482012E CaptureTest:10 - (Video, UYVY, 352x288, 16 bpp, 25 fps, 40.550 mbps)
PID:04C8012E TID:0482012E CaptureTest:11 - (Video, UYVY, 176x144, 16 bpp, 25 fps, 10.137 mbps)
PID:04C8012E TID:0482012E CaptureTest:12 - (Video, YUY2, 720x576, 16 bpp, 25 fps, 165.888 mbps)
PID:04C8012E TID:0482012E CaptureTest:13 - (Video, YUY2, 704x576, 16 bpp, 25 fps, 162.201 mbps)
PID:04C8012E TID:0482012E CaptureTest:14 - (Video, YUY2, 352x288, 16 bpp, 25 fps, 40.550 mbps)
PID:04C8012E TID:0482012E CaptureTest:15 - (Video, YUY2, 176x144, 16 bpp, 25 fps, 10.137 mbps)
PID:04C8012E TID:0482012E CaptureTest:16 - (Video, UYVY, 640x480, 16 bpp, 30 fps, 147.456 mbps)
PID:04C8012E TID:0482012E CaptureTest:17 - (Video, UYVY, 320x240, 16 bpp, 30 fps, 36.864 mbps)
PID:04C8012E TID:0482012E CaptureTest:18 - (Video, YUY2, 640x480, 16 bpp, 30 fps, 147.456 mbps)
PID:04C8012E TID:0482012E CaptureTest:19 - (Video, YUY2, 320x240, 16 bpp, 30 fps, 36.864 mbps)

这些信息是从哪里怎样打印出来的呢

WinMain中

hr = AddFiltersToGraph();
AddFiltersToGraph()中
hr = pCaptureGraphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
                                              &MEDIATYPE_Video, 
                                              pVideoCapture,
                                              IID_IAMStreamConfig, 
                                              (void **)&<span style="color:#ff0000;">pCaptureStreamConfig</span>);
RETAILMSG(DBGZONE_STATS, 
            (TEXT("%s: Capabilities of capture driver --->\r\n"), 
            APP_NAME));
        DumpStreamCaps(<span style="color:#ff0000;">pCaptureStreamConfig</span>);
DDumpStreamCaps(IAMStreamConfig *pStreamConfig) 中
hr = <span style="color:#ff0000;">pStreamConfig</span>-><span style="color:#000099;">GetNumberOfCapabilities</span>(&count, &size);
 int i = 0;
    while(i < count) {
        static TCHAR formatString[256];
    
        hr =<span style="color:#ff0000;"> pStreamConfig</span>-><span style="color:#000099;">GetStreamCaps</span>(
                                i,
                                &pMediaType,
                                pSCC);
        
        DumpMediaType(pMediaType, formatString, 256);
        RETAILMSG(DBGZONE_STATS, 
            (TEXT("%s:%d - (%s)\r\n"), 
            APP_NAME, i, formatString));
        DeleteMediaType(pMediaType);
        i++;
   }
1.pStreamConfig->GetNumberOfCapabilities(&count, &size);
2.hr = pStreamConfig->GetStreamCaps(
                                i,
                                &pMediaType,
                                pSCC);

此两条语句调用了 IAMStreamConfig接口,祥看上一篇介绍http://blog.csdn.net/zhangjikuan/article/details/42462715

这些信息在驱动中又是怎么定义的呢

camera\PDD\Params.h中定义了分辨率大小

#define TV_D1_PAL_HORZ_RES          (704)
#define TV_D1_PAL_VERT_RES          (576)
#define DVD_PAL_HORZ_RES            (720)
#define DVD_PAL_VERT_RES            (576)
#define CIF_PAL_HORZ_RES            (352)
#define CIF_PAL_VERT_RES            (288)
#define QCIF_PAL_HORZ_RES           (176)
#define QCIF_PAL_VERT_RES           (144)

#define TV_D1_NTSC_HORZ_RES         (704)
#define TV_D1_NTSC_VERT_RES         (480)
#define DVD_NTSC_HORZ_RES           (720)
#define DVD_NTSC_VERT_RES           (480)
#define CIF_NTSC_HORZ_RES           (352)
#define CIF_NTSC_VERT_RES           (240)
#define QCIF_NTSC_HORZ_RES          (176)
#define QCIF_NTSC_VERT_RES          (120)

#define VGA_HORZ_RES                (640)
#define VGA_VERT_RES                (480)
#define QVGA_HORZ_RES               (320)
#define QVGA_VERT_RES               (240)

#define MAX_X_RES               (DVD_PAL_HORZ_RES)
#define MAX_Y_RES               (DVD_PAL_VERT_RES)

#define HORZ_INFO_SPH_VAL       (202)
#define VERT_START_VAL          (24)

#define ENABLE_BT656            // using BT656 output from video decoder
// for AM3517: Do not Define ENABLE_PACk8 if using older App boards - 1013690, 1014473; Define if using newer app board 1015189
#define ENABLE_PACK8            // use 8-bit data width
//#define ENABLE_YUY2           // uncomment this to enable YUY2 output
#define ENABLE_PAL            // uncomment to enable PAL resolutions and frame rates

//#define ENABLE_DEINTERLACED_OUTPUT
#define ENABLE_PROGRESSIVE_INPUT
camera\PDD\Sensorformals.h中调用了宏函数MAKE_STREAM_MODE_YUY2和MAKE_STREAM_MODE_UYVY
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_TV_D1_NTSC_UYVY, TV_D1_NTSC_HORZ_RES, -TV_D1_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_TV_D1_NTSC_YUY2, TV_D1_NTSC_HORZ_RES, -TV_D1_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_DVD_NTSC_UYVY, DVD_NTSC_HORZ_RES, -DVD_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_DVD_NTSC_YUY2, DVD_NTSC_HORZ_RES, -DVD_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_CIF_NTSC_UYVY, CIF_NTSC_HORZ_RES, -CIF_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_CIF_NTSC_YUY2, CIF_NTSC_HORZ_RES, -CIF_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_QCIF_NTSC_UYVY, QCIF_NTSC_HORZ_RES, -QCIF_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_QCIF_NTSC_YUY2, QCIF_NTSC_HORZ_RES, -QCIF_NTSC_VERT_RES, 16, 30);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_TV_D1_PAL_UYVY, TV_D1_PAL_HORZ_RES, -TV_D1_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_TV_D1_PAL_YUY2, TV_D1_PAL_HORZ_RES, -TV_D1_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_DVD_PAL_UYVY, DVD_PAL_HORZ_RES, -DVD_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_DVD_PAL_YUY2, DVD_PAL_HORZ_RES, -DVD_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_CIF_PAL_UYVY, CIF_PAL_HORZ_RES, -CIF_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_CIF_PAL_YUY2, CIF_PAL_HORZ_RES, -CIF_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_QCIF_PAL_UYVY, QCIF_PAL_HORZ_RES, -QCIF_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_QCIF_PAL_YUY2, QCIF_PAL_HORZ_RES, -QCIF_PAL_VERT_RES, 16, 25);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_VGA_UYVY_30, VGA_HORZ_RES, -VGA_VERT_RES, 16, 30);
MAKE_STREAM_MODE_UYVY(DCAM_StreamMode_QVGA_UYVY_30, QVGA_HORZ_RES, -QVGA_VERT_RES, 16, 30);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_VGA_YUY2_30, VGA_HORZ_RES, -VGA_VERT_RES, 16, 30);
MAKE_STREAM_MODE_YUY2(DCAM_StreamMode_QVGA_YUY2_30, QVGA_HORZ_RES, -QVGA_VERT_RES, 16, 30);
camera\PDD\CameraDrvPdd.cpp中整合了这些函数在pcsDataRangeVideo数组中,APP中就是按照此数组的顺序将信息打印出来的

static PCS_DATARANGE_VIDEO pcsDataRangeVideo[] = 
    {
        &DCAM_StreamMode_DVD_NTSC_UYVY,
        &DCAM_StreamMode_TV_D1_NTSC_UYVY,
        &DCAM_StreamMode_CIF_NTSC_UYVY,
        &DCAM_StreamMode_QCIF_NTSC_UYVY,
#ifdef ENABLE_YUY2
        &DCAM_StreamMode_DVD_NTSC_YUY2,
        &DCAM_StreamMode_TV_D1_NTSC_YUY2,
        &DCAM_StreamMode_CIF_NTSC_YUY2,
        &DCAM_StreamMode_QCIF_NTSC_YUY2,
#endif
#ifdef ENABLE_PAL
        &DCAM_StreamMode_DVD_PAL_UYVY,
        &DCAM_StreamMode_TV_D1_PAL_UYVY,
        &DCAM_StreamMode_CIF_PAL_UYVY,
        &DCAM_StreamMode_QCIF_PAL_UYVY,
#ifdef ENABLE_YUY2
        &DCAM_StreamMode_DVD_PAL_YUY2,
        &DCAM_StreamMode_TV_D1_PAL_YUY2,
        &DCAM_StreamMode_CIF_PAL_YUY2,
        &DCAM_StreamMode_QCIF_PAL_YUY2,
#endif
#endif
        &DCAM_StreamMode_VGA_UYVY_30, 
        &DCAM_StreamMode_QVGA_UYVY_30,
#ifdef ENABLE_YUY2
        &DCAM_StreamMode_VGA_YUY2_30, 
        &DCAM_StreamMode_QVGA_YUY2_30,
#endif
    };

上面的数组在哪里调用出来的呢cameraDrvPdd.cpp中将数组中的所有成员都赋给了m_pModeVideoFormat[CAPTURE].pCsDataRangeVideo[i]

其实也赋给了preview和skill

for (int i = 0; i < count; i++) 
    {
         m_pModeVideoFormat[CAPTURE].pCsDataRangeVideo[i] = pcsDataRangeVideo[i];
    }

cameraDrvPdd.h中定义的m_pModeVideoFormat

// All the Video Formats supported by all the pins

    PPINVIDEOFORMAT   m_pModeVideoFormat;

camera\PDD\CameraDrvPdd.cpp中赋值

DWORD CCameraPdd::GetSensorModeInfo( ULONG ulModeType, PSENSORMODEINFO pSensorModeInfo )
{
    pSensorModeInfo->MemoryModel = m_SensorModeInfo[ulModeType].MemoryModel;
    pSensorModeInfo->MaxNumOfBuffers = m_SensorModeInfo[ulModeType].MaxNumOfBuffers;
    pSensorModeInfo->PossibleCount = m_SensorModeInfo[ulModeType].PossibleCount;
    pSensorModeInfo->VideoCaps.DefaultVideoControlCaps = DefaultVideoControlCaps[ulModeType];
    pSensorModeInfo->VideoCaps.CurrentVideoControlCaps = m_pModeVideoCaps[ulModeType].CurrentVideoControlCaps;
   <span style="color:#ff0000;"> pSensorModeInfo->pVideoFormat = &m_pModeVideoFormat[ulModeType];</span>
    
    return ERROR_SUCCESS;
}
<span style="font-family: Arial, Helvetica, sans-serif;">SensorModeInfo 的信息是从上面GetSensorModeInfo来的</span>
CCameraDevice::GetPDDPinInfo()
{
    SENSORMODEINFO SensorModeInfo;
    if (NULL == m_pStrmInstances)
    {
        return false;
    }


    for (UINT i=0; i < m_AdapterInfo.ulCTypes; i++)
    {
        if (ERROR_SUCCESS != PDDGetPinInfo(i, &SensorModeInfo))
        {
            return false ;
        }
        m_pStrmInstances[i].ulPossibleCount = SensorModeInfo.PossibleCount ;
        m_pStrmInstances[i].VideoCaps.DefaultVideoControlCaps = 


SensorModeInfo.VideoCaps.DefaultVideoControlCaps;
        m_pStrmInstances[i].VideoCaps.CurrentVideoControlCaps = 


SensorModeInfo.VideoCaps.CurrentVideoControlCaps;
        <span style="color:#ff0000;">m_pStrmInstances[i].pVideoFormat = SensorModeInfo.pVideoFormat;</span>


        if (SensorModeInfo.MemoryModel == CSPROPERTY_BUFFER_DRIVER &&
            (NULL == m_pPDDFuncTbl->PDD_AllocateBuffer || NULL == m_pPDDFuncTbl-


>PDD_DeAllocateBuffer))
        {
            return false;
        }


        if (SensorModeInfo.MemoryModel != CSPROPERTY_BUFFER_DRIVER &&
            (NULL == m_pPDDFuncTbl->PDD_RegisterClientBuffer || NULL == m_pPDDFuncTbl-


>PDD_UnRegisterClientBuffer))
        {
            return false;
        }
    }


    return true;
}
mdd\CaneraDevice.cpp中   CCameraDevice::AdapterHandleVideoControlRequests函数
switch (csProp.Id)
    {
    case CSPROPERTY_VIDEOCONTROL_CAPS:
        if (NULL == (pCsPropVideoControlCapsInput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer(pInBuf, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S), &dwError))))
        {
            break;
        }


        lIndex = pCsPropVideoControlCapsInput->StreamIndex;
        if (false == IsValidPin(lIndex))
        {
            DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid PinId\r\n"), this));
            break;
        }
<span style="font-family: Arial, Helvetica, sans-serif;">switch (csProp.Flags)</span>
        {
        case CSPROPERTY_TYPE_GET:
            *pdwBytesTransferred = sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S);
            if (NULL == (pCsPropVideoControlCapsOutput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer(pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError))))
            {
                dwError = ERROR_MORE_DATA;
                break;
            }


            //Copy the CSPROPERTY structure to the output buffer just in case!
            memcpy(pCsPropVideoControlCapsOutput, pCsPropVideoControlCapsInput, sizeof(CSPROPERTY));


            pCsPropVideoControlCapsOutput->StreamIndex      = lIndex;


            <span style="color:#ff0000;">if (true == GetPDDPinInfo())
            {
                pCsPropVideoControlCapsOutput->VideoControlCaps = m_pStrmInstances[lIndex].VideoCaps.CurrentVideoControlCaps;


                dwError = ERROR_SUCCESS;
            }</span>
            break;


        case CSPROPERTY_TYPE_SET:
            lIndex = pCsPropVideoControlCapsInput->StreamIndex;


            ulCaps = pCsPropVideoControlCapsInput->VideoControlCaps;
            if (ulCaps & ~(CS_VideoControlFlag_FlipHorizontal        |
                             CS_VideoControlFlag_FlipVertical          |
                             CS_VideoControlFlag_ExternalTriggerEnable |
                             CS_VideoControlFlag_Trigger               |
                             CS_VideoControlFlag_Sample_Scanned_Notification))
            {
                DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid flag specified as Video Control Caps.\r\n"), this));
                break;
            }


            if (false == IsValidPin(lIndex))
            {
                DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid pin index.\r\n"), this));
                break;
            }


            dwError = m_pPDDFuncTbl->PDD_HandleVideoControlCapsChanges(m_PDDContext, lIndex ,ulCaps);
            break;


        case CSPROPERTY_TYPE_DEFAULTVALUES:
            *pdwBytesTransferred = sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S);


            if (NULL == (pCsPropVideoControlCapsOutput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer(pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError))))
            {
                dwError = ERROR_MORE_DATA;
                break;
            }


            lIndex = pCsPropVideoControlCapsInput->StreamIndex;
            if (false == IsValidPin(lIndex))
            {
                DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid pin index.\r\n"), this));
                break;
            }


            //Copy the CSPROPERTY structure to the output buffer just in case!
            memcpy(pCsPropVideoControlCapsOutput, pCsPropVideoControlCapsInput, sizeof(CSPROPERTY));


            pCsPropVideoControlCapsOutput->StreamIndex      = lIndex;


            pCsPropVideoControlCapsOutput->VideoControlCaps =  m_pStrmInstances[lIndex].VideoCaps.DefaultVideoControlCaps;


            dwError = ERROR_SUCCESS;


            break;


        default:
            DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Request\r\n"), this));
            break;
        }
 至于PPINVIDEOFORMAT是什么还不知道,难道这就是供应用程序调用的了,待研究 
 

参考:http://justtotry.blog.163.com/blog/static/4463081220122554515509/



最上面的打印信息是在#define ENABLE_PAL  #define ENABLE_YUY2的情况下打印出来的

注意PAL制式时的帧率是25fps,NTSC和默认为30fps,在CaptureTest 的命令行中要指明。

其实摄像头上来的图像大小都是720x576大小的,至于这些打印出来的信息其实都是假的,并非真有这些设备,只是在驱动中对这些图像进行了一定算法的转换使其可以向用户程序输出这些格式的图像而已。

想给客户做的ce7系统camera驱动中支持所有格式的大小的图像,但是一直没有找到关于大小转换那部分的代码,待研究,希望看到能够指点下。









    

你可能感兴趣的:(设备信息,am3517,wince7,capturetest,IAMStreamConfig)