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

相关文章

Java实现检查多个时间段是否有重合

《Java实现检查多个时间段是否有重合》这篇文章主要为大家详细介绍了如何使用Java实现检查多个时间段是否有重合,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录流程概述步骤详解China编程步骤1:定义时间段类步骤2:添加时间段步骤3:检查时间段是否有重合步骤4:输出结果示例代码结语作

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

Java覆盖第三方jar包中的某一个类的实现方法

《Java覆盖第三方jar包中的某一个类的实现方法》在我们日常的开发中,经常需要使用第三方的jar包,有时候我们会发现第三方的jar包中的某一个类有问题,或者我们需要定制化修改其中的逻辑,那么应该如何... 目录一、需求描述二、示例描述三、操作步骤四、验证结果五、实现原理一、需求描述需求描述如下:需要在

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

linux下多个硬盘划分到同一挂载点问题

《linux下多个硬盘划分到同一挂载点问题》在Linux系统中,将多个硬盘划分到同一挂载点需要通过逻辑卷管理(LVM)来实现,首先,需要将物理存储设备(如硬盘分区)创建为物理卷,然后,将这些物理卷组成... 目录linux下多个硬盘划分到同一挂载点需要明确的几个概念硬盘插上默认的是非lvm总结Linux下多

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque