linux设备上的Onvif 实现9:检查是否支持该设备

来源:互联网 发布:互联网金融数据 编辑:程序博客网 时间:2024/04/29 13:03

前文获取了摄像头的2个通道的视频分辨率、帧率、码率、编码格式等信息,目的是为了判断我的linux设备能否支持该视频解码显示。 如果能够支持那么就大吉大利,一切OK!如果两个通道都不支持,那么就需要更麻烦的自动修改配置参数过程了,详细修改过程见后文说明。

2 我的判断函数

我的判断标准是:

#define  MAXWIDTH           640
#define  MAXHEIGHT          480
#define  MAXBITRATELIMIT   1536
#define  MAXFRAMERATE        25

/******************************************************************************
* Name:   MyIsSupportDevice
*
* Desc:   判断是否支持指定节点设备
* Param:
    int index, 指定节点序号
* Return: BOOL,  TRUE: support,  FALSE: not support
* Global:  
* Note:   如果两个通道都不满足要求才认定是不支持的设备 
* Author:   Tom-hongtao.gao
* -------------------------------------
* Log:   2013/07/24, Create this function by Tom-hongtao.gao
 ******************************************************************************/
BOOL MyIsSupportDevice(int index)
{
    BOOL bret=FALSE;
    int i;
    int support=0;   //支持的通道总数
   
    DEVICENODE * deviceode = DLFindbyIndex(index);
    if(!deviceode)
    {
        printf("--Error: DLFindbyIndex(%d) return NULL! \n", index);
        return FALSE;
    }

    for(i=0;i<2;i++)
    {
        /* 检查编码格式H264 */
        if(deviceode->profile[i].Encoding!=2)
        {
            printf("--Error: deviceode[%d]->profile[%d].Encoding is not H264! \n",index,i);
            continue;
        }

        /* 检查编码参数H264Profile */
        if(deviceode->profile[i].H264Profile<0)
        {
            printf("--Error: deviceode[%d]->profile[%d].H264Profile is not unkonwn! \n",index,i);
            continue;
        }

        /* 检查分辨率640x480 */
        if(deviceode->profile[i].Width > MAXWIDTH)
        {
            printf("--Error: deviceode[%d]->profile[%d].Width is more than %d! \n",index,i, MAXWIDTH);
            continue;
        }
        if(deviceode->profile[i].Height > MAXHEIGHT)
        {
            printf("--Error: deviceode[%d]->profile[%d].Height is more than %d! \n",index,i,MAXHEIGHT);
            continue;
        }

        /* 检查帧率25 */
        if(deviceode->profile[i].FrameRateLimit > MAXFRAMERATE)
        {
            printf("--Error: deviceode[%d]->profile[%d].FrameRateLimit is more than %d fps! \n",index,i, MAXFRAMERATE);
            continue;
        }

        /* 检查码率1.5M */       
        /* 发现各种摄像头分包数、分包大小不同。
           有的每包1422byte,分包数超过15包
           有的每包8000byte,分包数随码率而变,
              512K 下分为3包,解码正常
              1024K下分为4包,I帧偶尔超过30K 
              1280K下分为5包,I帧经常超过30K
              1536K下分为7包,I帧超过40K
        */
        if(deviceode->profile[i].BitrateLimit > MAXBITRATELIMIT)
        {
            printf("--Error: deviceode[%d]->profile[%d].BitrateLimit is more than %d Kbs! \n",index,i,MAXBITRATELIMIT);
            continue;
        }
        
        deviceode->profile[i].support=1;  //通过检查设置为支持
        printf("--Find support profile: deviceode[%d]->profile[%d]. \n",index,i);
        support++;
    }

    if(support > 0)
        bret=TRUE;
    else
        bret=FALSE;
    return bret;
}

原创粉丝点击