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

相关文章

golang版本升级如何实现

《golang版本升级如何实现》:本文主要介绍golang版本升级如何实现问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录golanwww.chinasem.cng版本升级linux上golang版本升级删除golang旧版本安装golang最新版本总结gola

SpringBoot中SM2公钥加密、私钥解密的实现示例详解

《SpringBoot中SM2公钥加密、私钥解密的实现示例详解》本文介绍了如何在SpringBoot项目中实现SM2公钥加密和私钥解密的功能,通过使用Hutool库和BouncyCastle依赖,简化... 目录一、前言1、加密信息(示例)2、加密结果(示例)二、实现代码1、yml文件配置2、创建SM2工具

Mysql实现范围分区表(新增、删除、重组、查看)

《Mysql实现范围分区表(新增、删除、重组、查看)》MySQL分区表的四种类型(范围、哈希、列表、键值),主要介绍了范围分区的创建、查询、添加、删除及重组织操作,具有一定的参考价值,感兴趣的可以了解... 目录一、mysql分区表分类二、范围分区(Range Partitioning1、新建分区表:2、分

MySQL 定时新增分区的实现示例

《MySQL定时新增分区的实现示例》本文主要介绍了通过存储过程和定时任务实现MySQL分区的自动创建,解决大数据量下手动维护的繁琐问题,具有一定的参考价值,感兴趣的可以了解一下... mysql创建好分区之后,有时候会需要自动创建分区。比如,一些表数据量非常大,有些数据是热点数据,按照日期分区MululbU

MySQL中查找重复值的实现

《MySQL中查找重复值的实现》查找重复值是一项常见需求,比如在数据清理、数据分析、数据质量检查等场景下,我们常常需要找出表中某列或多列的重复值,具有一定的参考价值,感兴趣的可以了解一下... 目录技术背景实现步骤方法一:使用GROUP BY和HAVING子句方法二:仅返回重复值方法三:返回完整记录方法四:

IDEA中新建/切换Git分支的实现步骤

《IDEA中新建/切换Git分支的实现步骤》本文主要介绍了IDEA中新建/切换Git分支的实现步骤,通过菜单创建新分支并选择是否切换,创建后在Git详情或右键Checkout中切换分支,感兴趣的可以了... 前提:项目已被Git托管1、点击上方栏Git->NewBrancjsh...2、输入新的分支的

Linux中压缩、网络传输与系统监控工具的使用完整指南

《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

Python实现对阿里云OSS对象存储的操作详解

《Python实现对阿里云OSS对象存储的操作详解》这篇文章主要为大家详细介绍了Python实现对阿里云OSS对象存储的操作相关知识,包括连接,上传,下载,列举等功能,感兴趣的小伙伴可以了解下... 目录一、直接使用代码二、详细使用1. 环境准备2. 初始化配置3. bucket配置创建4. 文件上传到os

关于集合与数组转换实现方法

《关于集合与数组转换实现方法》:本文主要介绍关于集合与数组转换实现方法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、Arrays.asList()1.1、方法作用1.2、内部实现1.3、修改元素的影响1.4、注意事项2、list.toArray()2.1、方

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互