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

相关文章

C++中RAII资源获取即初始化

《C++中RAII资源获取即初始化》RAII通过构造/析构自动管理资源生命周期,确保安全释放,本文就来介绍一下C++中的RAII技术及其应用,具有一定的参考价值,感兴趣的可以了解一下... 目录一、核心原理与机制二、标准库中的RAII实现三、自定义RAII类设计原则四、常见应用场景1. 内存管理2. 文件操

C++中零拷贝的多种实现方式

《C++中零拷贝的多种实现方式》本文主要介绍了C++中零拷贝的实现示例,旨在在减少数据在内存中的不必要复制,从而提高程序性能、降低内存使用并减少CPU消耗,零拷贝技术通过多种方式实现,下面就来了解一下... 目录一、C++中零拷贝技术的核心概念二、std::string_view 简介三、std::stri

C++高效内存池实现减少动态分配开销的解决方案

《C++高效内存池实现减少动态分配开销的解决方案》C++动态内存分配存在系统调用开销、碎片化和锁竞争等性能问题,内存池通过预分配、分块管理和缓存复用解决这些问题,下面就来了解一下... 目录一、C++内存分配的性能挑战二、内存池技术的核心原理三、主流内存池实现:TCMalloc与Jemalloc1. TCM

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

Linux脚本(shell)的使用方式

《Linux脚本(shell)的使用方式》:本文主要介绍Linux脚本(shell)的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录概述语法详解数学运算表达式Shell变量变量分类环境变量Shell内部变量自定义变量:定义、赋值自定义变量:引用、修改、删

Python实现精准提取 PDF中的文本,表格与图片

《Python实现精准提取PDF中的文本,表格与图片》在实际的系统开发中,处理PDF文件不仅限于读取整页文本,还有提取文档中的表格数据,图片或特定区域的内容,下面我们来看看如何使用Python实... 目录安装 python 库提取 PDF 文本内容:获取整页文本与指定区域内容获取页面上的所有文本内容获取

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.

canal实现mysql数据同步的详细过程

《canal实现mysql数据同步的详细过程》:本文主要介绍canal实现mysql数据同步的详细过程,本文通过实例图文相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的... 目录1、canal下载2、mysql同步用户创建和授权3、canal admin安装和启动4、canal

Nexus安装和启动的实现教程

《Nexus安装和启动的实现教程》:本文主要介绍Nexus安装和启动的实现教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Nexus下载二、Nexus安装和启动三、关闭Nexus总结一、Nexus下载官方下载链接:DownloadWindows系统根