linux设备上的Onvif 实现8:编写媒体信息获取程序

2024-06-23 08:38

本文主要是介绍linux设备上的Onvif 实现8:编写媒体信息获取程序,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1   背景

   在前文中获取到了媒体信息URI   http://192.168.15.240/onvif/Media, 本文将向这个地址查询设备的具体媒体配置信息,将返回视频源分辨率、编码器分辨率、编码格式、帧率、码率、多播地址等信息。

2 GetProfiles

获取媒体信息函数是GetProfiles,在我的版本中实际名称是:

SOAP_FMAC5 int SOAP_FMAC6 soap_call___ns8__GetProfiles(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct _ns8__GetProfiles *ns8__GetProfiles, struct _ns8__GetProfilesResponse *ns8__GetProfilesResponse)
我只研究了关于Media类别的配置信息,其它类别没有尝试过。

事实上,一个摄像头一般都有2个通道,一个是主通道,提供高清视频,用于本地查看及录像;另一个是子通道,提供普通视频,用于远程查看(例如手机访问、远程PC访问)。这两个通道各有一份配置文件,因此,该函数应答包中包含两份数据。

3 我的代码实例:

/******************************************************************************
* Name:   MyGetProfiles
*
* Desc:   获取指定设备节点的媒体信息
    struct soap *soap,
    int index, 设备节点序号

* Return: BOOL,  TRUE: success,  FALSE: fail
* Global:  
* Note:  
* Author:   Tom-hongtao.gao
* -------------------------------------
* Log:   2013/07/24, Create this function by Tom-hongtao.gao
 ******************************************************************************/
BOOL MyGetProfiles(struct soap *soap, int index)
{   
    BOOL bret=FALSE;
    int result = 0;
   
    DEVICENODE * deviceode = DLFindbyIndex(index);
    if(!deviceode)
    {
        printf("--Error: DLFindbyIndex(%d) return NULL! \n", index);
        return FALSE;
    }
    if(deviceode->mediauri==NULL || strlen(deviceode->mediauri)==0)
    {
        printf("--Error: deviceode->mediauri is NULL! \n");
        return FALSE;
    }
   
    struct _ns8__GetProfiles getProfilesReq;
    struct _ns8__GetProfilesResponse getProfilesResponse={0};  
    result = soap_call___ns8__GetProfiles(soap, deviceode->mediauri, NULL, &getProfilesReq, &getProfilesResponse);
    if(result==-1)       
    {
        printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
        result = soap->error;
        bret = FALSE;       
    }
    else
    {       
        if(getProfilesResponse.__sizeProfiles<=0)
        {
            printf(" GetProfiles  failed!  result=%d \n",result);
            bret = FALSE; 
        }
        else
        {
            printf(" GetProfiles  OK!  result=%d \n",result);
            int i;
            int count = getProfilesResponse.__sizeProfiles;
            //printf(" getProfilesResponse.__sizeProfiles=%d \n", count);
           
            for(i=0;i<2;i++)
            {  
                #if 0
                printf(" Profiles[%d]->Name=%s \n", i,getProfilesResponse.Profiles->Name);
                printf(" Profiles[%d]->token=%s \n",i,getProfilesResponse.Profiles->token);
                printf(" Profiles[%d]->fixed=%s \n", i,getProfilesResponse.Profiles->fixed);
                printf(" Profiles[%d]->VideoEncoderConfiguration->Name=%s \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->Name); 
                printf(" Profiles[%d]->VideoEncoderConfiguration->token=%s \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->token);
                printf(" Profiles[%d]->VideoEncoderConfiguration->Encoding=%d \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->Encoding);
                printf(" Profiles[%d]->VideoEncoderConfiguration->Resolution->Width=%d \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->Resolution->Width);
                printf(" Profiles[%d]->VideoEncoderConfiguration->Resolution->Height=%d \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->Resolution->Height);
                printf(" Profiles[%d]->VideoEncoderConfiguration->RateControl->FrameRateLimit=%d \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->RateControl->FrameRateLimit);
                printf(" Profiles[%d]->VideoEncoderConfiguration->RateControl->BitrateLimit=%d \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->RateControl->BitrateLimit);
                printf(" Profiles[%d]->VideoEncoderConfiguration->H264->H264Profile=%d \n", i,getProfilesResponse.Profiles->VideoEncoderConfiguration->H264->H264Profile);
                #endif
               
                PROFILE profile;
                memset(&profile, 0, sizeof(PROFILE));
                strncpy(profile.Name, getProfilesResponse.Profiles->Name, MAXSTRLEN);
                strncpy(profile.token,getProfilesResponse.Profiles->token, MAXSTRLEN);
                strncpy(profile.VideoEncoderConfigurationtoken,getProfilesResponse.Profiles->VideoEncoderConfiguration->token, MAXSTRLEN);
                profile.Encoding       = getProfilesResponse.Profiles->VideoEncoderConfiguration->Encoding;
                profile.H264Profile    = getProfilesResponse.Profiles->VideoEncoderConfiguration->H264->H264Profile;
                profile.Width          = getProfilesResponse.Profiles->VideoEncoderConfiguration->Resolution->Width;
                profile.Height         = getProfilesResponse.Profiles->VideoEncoderConfiguration->Resolution->Height;
                profile.FrameRateLimit = getProfilesResponse.Profiles->VideoEncoderConfiguration->RateControl->FrameRateLimit;
                profile.BitrateLimit   = getProfilesResponse.Profiles->VideoEncoderConfiguration->RateControl->BitrateLimit;
                profile.support        = 0;           
                DLSetProfile(index, i, &profile);
                //PrintfNodebyIndex(index);
                getProfilesResponse.Profiles++;  //???ò??????profile
            }
            bret = TRUE;     

        }       
    }

    soap_end(soap);
    return bret;
   
}

4 实际报文包

电脑IP 192.168.0.75,发出GetProfiles命令,网络摄像头应答。

这篇关于linux设备上的Onvif 实现8:编写媒体信息获取程序的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1086662

相关文章

Redis客户端连接机制的实现方案

《Redis客户端连接机制的实现方案》本文主要介绍了Redis客户端连接机制的实现方案,包括事件驱动模型、非阻塞I/O处理、连接池应用及配置优化,具有一定的参考价值,感兴趣的可以了解一下... 目录1. Redis连接模型概述2. 连接建立过程详解2.1 连php接初始化流程2.2 关键配置参数3. 最大连

Python实现网格交易策略的过程

《Python实现网格交易策略的过程》本文讲解Python网格交易策略,利用ccxt获取加密货币数据及backtrader回测,通过设定网格节点,低买高卖获利,适合震荡行情,下面跟我一起看看我们的第一... 网格交易是一种经典的量化交易策略,其核心思想是在价格上下预设多个“网格”,当价格触发特定网格时执行买

Oracle数据库定时备份脚本方式(Linux)

《Oracle数据库定时备份脚本方式(Linux)》文章介绍Oracle数据库自动备份方案,包含主机备份传输与备机解压导入流程,强调需提前全量删除原库数据避免报错,并需配置无密传输、定时任务及验证脚本... 目录说明主机脚本备机上自动导库脚本整个自动备份oracle数据库的过程(建议全程用root用户)总结

SQL Server跟踪自动统计信息更新实战指南

《SQLServer跟踪自动统计信息更新实战指南》本文详解SQLServer自动统计信息更新的跟踪方法,推荐使用扩展事件实时捕获更新操作及详细信息,同时结合系统视图快速检查统计信息状态,重点强调修... 目录SQL Server 如何跟踪自动统计信息更新:深入解析与实战指南 核心跟踪方法1️⃣ 利用系统目录

Linux如何查看文件权限的命令

《Linux如何查看文件权限的命令》Linux中使用ls-R命令递归查看指定目录及子目录下所有文件和文件夹的权限信息,以列表形式展示权限位、所有者、组等详细内容... 目录linux China编程查看文件权限命令输出结果示例这里是查看tomcat文件夹总结Linux 查看文件权限命令ls -l 文件或文件夹

idea的终端(Terminal)cmd的命令换成linux的命令详解

《idea的终端(Terminal)cmd的命令换成linux的命令详解》本文介绍IDEA配置Git的步骤:安装Git、修改终端设置并重启IDEA,强调顺序,作为个人经验分享,希望提供参考并支持脚本之... 目录一编程、设置前二、前置条件三、android设置四、设置后总结一、php设置前二、前置条件

python设置环境变量路径实现过程

《python设置环境变量路径实现过程》本文介绍设置Python路径的多种方法:临时设置(Windows用`set`,Linux/macOS用`export`)、永久设置(系统属性或shell配置文件... 目录设置python路径的方法临时设置环境变量(适用于当前会话)永久设置环境变量(Windows系统

Python对接支付宝支付之使用AliPay实现的详细操作指南

《Python对接支付宝支付之使用AliPay实现的详细操作指南》支付宝没有提供PythonSDK,但是强大的github就有提供python-alipay-sdk,封装里很多复杂操作,使用这个我们就... 目录一、引言二、准备工作2.1 支付宝开放平台入驻与应用创建2.2 密钥生成与配置2.3 安装ali

Spring Security 单点登录与自动登录机制的实现原理

《SpringSecurity单点登录与自动登录机制的实现原理》本文探讨SpringSecurity实现单点登录(SSO)与自动登录机制,涵盖JWT跨系统认证、RememberMe持久化Token... 目录一、核心概念解析1.1 单点登录(SSO)1.2 自动登录(Remember Me)二、代码分析三、

Python获取浏览器Cookies的四种方式小结

《Python获取浏览器Cookies的四种方式小结》在进行Web应用程序测试和开发时,获取浏览器Cookies是一项重要任务,本文我们介绍四种用Python获取浏览器Cookies的方式,具有一定的... 目录什么是 Cookie?1.使用Selenium库获取浏览器Cookies2.使用浏览器开发者工具