zoukankan      html  css  js  c++  java
  • Onvif开发之服务端成功对接Rtsp视频流篇

    面篇介绍onvif服务端的发现功能,继续在之前的代码基础上完成一个RTSP流的工作,也就是客户端通过ONVIF协议来预览设备端
    在这个之前必须确定几个简单的条件
    1 设备端能被发现
    2 设备端支持RTSP协议,并且能够通过VLC进行正常的预览


    通过onvif协议设备需要做的几个基本事情:
    1  __tds__GetCapabilities获取设备能力
    2  __trt__GetProfiles获取设备的配置信息
    3  获取前段设备的视频编码和视频源的一些基本需要的信息
    4 __trt__GetStreamUri后去设备的URi,通过RTSP获取视频流


    接口函数有了,实现的时候当然也需要注意匹配,需要把设备的一些主要信息对应匹配到Onvif协议中,下面一个函数一个函数的具体实现如下,在需要注意的地方我都加上了对应的注释,如果还有不清楚的地方可以留言,我会尽量尽我所知道的告诉大家
    1 __tds__GetCapabilities,此函数是获取设备端的能力的函数,在这里需要预览,所以基本的media和device的一些基本信息是需要填写的

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. Capabilities__Device_Choice:  
    2.     tds__GetCapabilitiesResponse->Capabilities->Device = (struct tt__DeviceCapabilities *)soap_malloc(soap,sizeof(struct tt__DeviceCapabilities));  
    3.     memset(tds__GetCapabilitiesResponse->Capabilities->Device, 0, sizeof(struct tt__DeviceCapabilities));  
    4.       
    5.     tds__GetCapabilitiesResponse->Capabilities->Device->XAddr = (char *)soap_malloc(soap, sizeof(char) * MAX_64_LEN );  
    6.     memset(tds__GetCapabilitiesResponse->Capabilities->Device->XAddr, 0, sizeof(char) * MAX_64_LEN);  
    7.      //填写设备的ip地址以及需要通过onvif协议通信的端口号  
    8.     sprintf(tds__GetCapabilitiesResponse->Capabilities->Device->XAddr, "%s/onvif/device_service", "192.168.12.135:8899");  
    9.       
    10.     //设备的一些基本能力值,是否支持那些功能,如果在开发的时候,如果前段设备支持这些功能的话,就可以直接填写true,否则填写false  
    11.     tds__GetCapabilitiesResponse->Capabilities->Device->Network = (struct tt__NetworkCapabilities *)soap_malloc(soap, sizeof(struct tt__NetworkCapabilities ));  
    12.     memset(tds__GetCapabilitiesResponse->Capabilities->Device->Network, 0, sizeof(struct tt__NetworkCapabilities ));  
    13.     tds__GetCapabilitiesResponse->Capabilities->Device->Network->IPFilter = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));  
    14.     *(tds__GetCapabilitiesResponse->Capabilities->Device->Network->IPFilter) = xsd__boolean__false_; // xsd__boolean__true_   
    15.     tds__GetCapabilitiesResponse->Capabilities->Device->Network->ZeroConfiguration= (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));  
    16.     *(tds__GetCapabilitiesResponse->Capabilities->Device->Network->ZeroConfiguration) = xsd__boolean__true_; // xsd__boolean__false_   
    17.     tds__GetCapabilitiesResponse->Capabilities->Device->Network->IPVersion6 = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));  
    18.     *(tds__GetCapabilitiesResponse->Capabilities->Device->Network->IPVersion6) = xsd__boolean__false_; // xsd__boolean__true_   
    19.     tds__GetCapabilitiesResponse->Capabilities->Device->Network->DynDNS = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));  
    20.     *(tds__GetCapabilitiesResponse->Capabilities->Device->Network->DynDNS) = xsd__boolean__true_; // xsd__boolean__false_   
    21.   
    22.     tds__GetCapabilitiesResponse->Capabilities->Device->System = (struct tt__SystemCapabilities *)soap_malloc(soap, sizeof(struct tt__SystemCapabilities));  
    23.     memset( tds__GetCapabilitiesResponse->Capabilities->Device->System, 0, sizeof(struct tt__SystemCapabilities));  
    24.     tds__GetCapabilitiesResponse->Capabilities->Device->System->DiscoveryResolve = xsd__boolean__true_;   
    25.     tds__GetCapabilitiesResponse->Capabilities->Device->System->DiscoveryBye     = xsd__boolean__true_;   
    26.     tds__GetCapabilitiesResponse->Capabilities->Device->System->RemoteDiscovery  = xsd__boolean__false_;   
    27.     tds__GetCapabilitiesResponse->Capabilities->Device->System->SystemBackup     = xsd__boolean__false_;   
    28.     tds__GetCapabilitiesResponse->Capabilities->Device->System->SystemLogging    = xsd__boolean__false_;   
    29.     tds__GetCapabilitiesResponse->Capabilities->Device->System->FirmwareUpgrade  = xsd__boolean__false_;   
    30.     tds__GetCapabilitiesResponse->Capabilities->Device->System->__sizeSupportedVersions = 1;   
    31.     tds__GetCapabilitiesResponse->Capabilities->Device->System->SupportedVersions = (struct tt__OnvifVersion *)soap_malloc(soap, sizeof(struct tt__OnvifVersion));    
    32.     tds__GetCapabilitiesResponse->Capabilities->Device->System->SupportedVersions->Major = 2;   
    33.     tds__GetCapabilitiesResponse->Capabilities->Device->System->SupportedVersions->Minor = 0;   
    34.   
    35.       // 设备IO的一些支持  
    36.     tds__GetCapabilitiesResponse->Capabilities->Device->IO = (struct tt__IOCapabilities *)soap_malloc(soap, sizeof(struct tt__IOCapabilities));  
    37.     memset(tds__GetCapabilitiesResponse->Capabilities->Device->IO, 0, sizeof(struct tt__IOCapabilities));  
    38.     tds__GetCapabilitiesResponse->Capabilities->Device->IO->InputConnectors = (int *)soap_malloc(soap, sizeof(int));   
    39.     *(tds__GetCapabilitiesResponse->Capabilities->Device->IO->InputConnectors) = 1;   
    40.     tds__GetCapabilitiesResponse->Capabilities->Device->IO->RelayOutputs = (int *)soap_malloc(soap, sizeof(int));   
    41.     *(tds__GetCapabilitiesResponse->Capabilities->Device->IO->RelayOutputs) = 1;   
    42.       
    43.     tds__GetCapabilitiesResponse->Capabilities->Device->Security = (struct tt__SecurityCapabilities *)soap_malloc(soap, sizeof(struct tt__SecurityCapabilities));  
    44.     memset(tds__GetCapabilitiesResponse->Capabilities->Device->Security, 0, sizeof(struct tt__SecurityCapabilities));  
    45.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->TLS1_x002e1          = xsd__boolean__false_;  
    46.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->TLS1_x002e2          = xsd__boolean__false_;  
    47.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->OnboardKeyGeneration = xsd__boolean__false_;  
    48.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->AccessPolicyConfig   = xsd__boolean__false_;  
    49.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->X_x002e509Token      = xsd__boolean__false_;  
    50.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->SAMLToken            = xsd__boolean__false_;  
    51.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->KerberosToken        = xsd__boolean__false_;  
    52.     tds__GetCapabilitiesResponse->Capabilities->Device->Security->RELToken             = xsd__boolean__false_;  
    53. Capabilities__Imaging_Choice:  
    54.      //Imaging的一些基本信息,关于视频颜色,IRCut的一些基本信息  
    55.     tds__GetCapabilitiesResponse->Capabilities->Imaging = (struct tt__ImagingCapabilities *)soap_malloc(soap,sizeof(struct tt__ImagingCapabilities));  
    56.     memset(tds__GetCapabilitiesResponse->Capabilities->Imaging, 0, sizeof(struct tt__ImagingCapabilities));  
    57.   
    58.     tds__GetCapabilitiesResponse->Capabilities->Imaging->XAddr = (char *)soap_malloc(soap, sizeof(char) * MAX_64_LEN );  
    59.     memset(tds__GetCapabilitiesResponse->Capabilities->Imaging->XAddr, '', sizeof(char) * MAX_64_LEN);  
    60.     sprintf(tds__GetCapabilitiesResponse->Capabilities->Imaging->XAddr, "%s/onvif/imaging_service","192.168.12.135:8899");  
    61.   
    62. Capabilities__Media__Choice:  
    63.     tds__GetCapabilitiesResponse->Capabilities->Media = (struct tt__MediaCapabilities *)soap_malloc(soap,sizeof(struct tt__MediaCapabilities));  
    64.     memset(tds__GetCapabilitiesResponse->Capabilities->Media, 0, sizeof(struct tt__MediaCapabilities));  
    65.   
    66.     tds__GetCapabilitiesResponse->Capabilities->Media->XAddr = (char *)soap_malloc(soap, sizeof(char) * MAX_64_LEN );  
    67.     memset(tds__GetCapabilitiesResponse->Capabilities->Media->XAddr, 0, sizeof(char) * MAX_64_LEN);  
    68.     sprintf(tds__GetCapabilitiesResponse->Capabilities->Media->XAddr, "%s/onvif/media_service", "192.168.12.135:8899");  
    69.   
    70.     tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities = (struct tt__RealTimeStreamingCapabilities *)soap_malloc(soap,   
    71.             sizeof(struct tt__RealTimeStreamingCapabilities));  
    72.     memset(tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities, 0, sizeof(struct tt__RealTimeStreamingCapabilities));  
    73.     tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities->RTPMulticast   = (enum xsd__boolean *)soap_malloc(soap,sizeof(int));  
    74.     *tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities->RTPMulticast  = xsd__boolean__false_;  
    75.     tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities->RTP_USCORETCP  = (enum xsd__boolean*)soap_malloc(soap,sizeof(int));  
    76.     *tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities->RTP_USCORETCP = xsd__boolean__true_;  
    77.     tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities->RTP_USCORERTSP_USCORETCP = (enum xsd__boolean*)soap_malloc(soap,sizeof(int));  
    78.     *tds__GetCapabilitiesResponse->Capabilities->Media->StreamingCapabilities->RTP_USCORERTSP_USCORETCP = xsd__boolean__true_;  

    2 __tds__GetServices函数的一些基本信息的填写

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. tds__GetServicesResponse->__sizeService = 1;  
    2. tds__GetServicesResponse->Service = (struct tds__Service *)soap_malloc(soap, sizeof(struct tds__Service));  
    3. tds__GetServicesResponse->Service[0].Namespace = (char *)soap_malloc(soap, sizeof(char)* INFO_LENGTH);  
    4. strcpy(tds__GetServicesResponse->Service[0].Namespace, "http://www.onvif.org/ver10/events/wsdl");  
    5. tds__GetServicesResponse->Service[0].XAddr     = (char *)soap_malloc(soap, sizeof(char)* INFO_LENGTH);  
    6. strcpy(tds__GetServicesResponse->Service[0].XAddr, "http://192.168.12.135/onvif/services");  
    7.   
    8. tds__GetServicesResponse->Service[0].Capabilities = NULL;  
    9. tds__GetServicesResponse->Service[0].Version = (struct tt__OnvifVersion *)soap_malloc(soap, sizeof(struct tt__OnvifVersion));  
    10. tds__GetServicesResponse->Service[0].Version->Major = 0;  
    11. tds__GetServicesResponse->Service[0].Version->Minor = 3;  
    12.   
    13. tds__GetServicesResponse->Service[0].__size = 0;  
    14. tds__GetServicesResponse->Service[0].__any = NULL;  
    15. tds__GetServicesResponse->Service[0].__anyAttribute = NULL;  

    3  __trt__GetProfiles获取设备的配置信息

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1.         // VideoSourceConfiguration   
    2.         trt__GetProfilesResponse->Profiles[i].Name = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);  
    3.         memset(trt__GetProfilesResponse->Profiles[i].Name, '', sizeof(char)*MAX_PROF_TOKEN);  
    4.         //profiles的名字,和token不同,实际请求的时候都是需要对应的token值来获取的  
    5.         strcpy(trt__GetProfilesResponse->Profiles[i].Name, "test_profile");  
    6.   
    7.         trt__GetProfilesResponse->Profiles[i].token = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);  
    8.         memset(trt__GetProfilesResponse->Profiles[i].token, '', sizeof(char)*MAX_PROF_TOKEN);  
    9.         //此token也就是每次需要获取对应profiles的一些信息的时候,就需要在请求的时候填写此对应的token来,来进行验证判断   
    10.         strcpy(trt__GetProfilesResponse->Profiles[i].token, "test_token");  
    11.   
    12.         trt__GetProfilesResponse->Profiles[i].fixed = (enum xsd__boolean *)soap_malloc(soap, sizeof(int));  
    13.         memset(trt__GetProfilesResponse->Profiles[i].fixed, 0, sizeof(int));  
    14.         *(trt__GetProfilesResponse->Profiles[i].fixed) = (enum xsd__boolean )0;  
    15.         trt__GetProfilesResponse->Profiles[i].__anyAttribute = NULL;  
    16.   
    17.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration = (struct tt__VideoSourceConfiguration *)soap_malloc(soap,sizeof(struct tt__VideoSourceConfiguration));  
    18.         memset(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration, 0, sizeof(struct tt__VideoSourceConfiguration));  
    19.   
    20.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Name = (char *)soap_malloc(soap,sizeof(char) * MAX_PROF_TOKEN);  
    21.         memset(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Name, '', sizeof(char) * MAX_PROF_TOKEN);  
    22.         // 类似与上面,VideoSource Name,  
    23.         strcpy(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Name, "test_vsname");  
    24.   
    25.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->token = (char *)soap_malloc(soap,sizeof(char) * MAX_PROF_TOKEN);  
    26.         memset(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->token, '', sizeof(char) * MAX_PROF_TOKEN);  
    27.         //求不同码流的视频源信息需要此token值匹配  
    28.         strcpy(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->token, "test_vsoken");  
    29.   
    30.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->SourceToken = (char *)soap_malloc(soap,sizeof(char) * MAX_PROF_TOKEN);  
    31.         memset(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->SourceToken, '', sizeof(char) * MAX_PROF_TOKEN);  
    32.      
    33.         strcpy(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->SourceToken, "test_vstoken");   
    34.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->UseCount = 1;   
    35.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Bounds = (struct tt__IntRectangle *)soap_malloc(soap, sizeof(struct tt__IntRectangle));   
    36.         memset(trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Bounds, 0, sizeof(struct tt__IntRectangle));   
    37.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Bounds->x = 0;   
    38.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Bounds->y = 0;   
    39.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Bounds->width = 1280;   
    40.         trt__GetProfilesResponse->Profiles[i].VideoSourceConfiguration->Bounds->height = 720;   
    41.         // VideoEncoderConfiguration   
    42.         trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration = (struct tt__VideoEncoderConfiguration *)soap_malloc(soap, sizeof(struct tt__VideoEncoderConfiguration)) ;  
    43.         memset(trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration, '', sizeof(struct tt__VideoEncoderConfiguration));   
    44.         trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->Name = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);   
    45.         memset(trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->Name, '', sizeof(char)*MAX_PROF_TOKEN);   
    46.         strcpy(trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->Name, "test_vename");   
    47.         trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->token = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);   
    48.         memset(trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->token, '', sizeof(char)*MAX_PROF_TOKEN);   
    49.         strcpy(trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->token, "test_vstoken");   
    50.         trt__GetProfilesResponse->Profiles[i].VideoEncoderConfiguration->UseCount = 1;   
    51.        //当然在实际开发的过程中最好把单个也实现了,也就是__trt__GetProfile函数接口,此接口是根据对应的请求的token来获取对应的信息的!  

    4  视频源已经视频编码必须填充的一些基本需要填写的一些关键信息

         (1)__trt__GetVideoEncoderConfiguration函数接口一些主要信息

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //请求的时候需要匹配的一些基本信息  
    2. trt__GetVideoEncoderConfigurationResponse->Configuration->Name = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);  
    3. memset(trt__GetVideoEncoderConfigurationResponse->Configuration->Name, '', sizeof(char)*MAX_PROF_TOKEN);  
    4. strcpy(trt__GetVideoEncoderConfigurationResponse->Configuration->Name, "test_vsname");  
    5.   
    6. trt__GetVideoEncoderConfigurationResponse->Configuration->token = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);  
    7. memset(trt__GetVideoEncoderConfigurationResponse->Configuration->token, '', sizeof(char)*MAX_PROF_TOKEN);  
    8. strcpy(trt__GetVideoEncoderConfigurationResponse->Configuration->token, "test_vstoken");  
    9.   
    10. trt__GetVideoEncoderConfigurationResponse->Configuration->UseCount = 1;  
    11. trt__GetVideoEncoderConfigurationResponse->Configuration->Quality = 100;  
    12. //根据前端设备时间支持的编码格式选择对应的值,因为我测试的是设备只支持H264 ,所以选了2  
    13. trt__GetVideoEncoderConfigurationResponse->Configuration->Encoding = (enum tt__VideoEncoding) 2;   // JPEG = 0 , MPEG = 1, H264 = 2;   
    14.   
    15. trt__GetVideoEncoderConfigurationResponse->Configuration->Resolution = (struct tt__VideoResolution *)soap_malloc(soap,sizeof(struct tt__VideoResolution));  
    16. memset(trt__GetVideoEncoderConfigurationResponse->Configuration->Resolution, 0 , sizeof(struct tt__VideoResolution));  
    17. // 请求的视频的分辨率,对应前端设备填写对应的值,我这是1280 * 720  
    18. trt__GetVideoEncoderConfigurationResponse->Configuration->Resolution->Width  = 1280;  
    19. trt__GetVideoEncoderConfigurationResponse->Configuration->Resolution->Height = 720;  
    20.   
    21. trt__GetVideoEncoderConfigurationResponse->Configuration->RateControl = (struct tt__VideoRateControl *)soap_malloc(soap, sizeof(struct tt__VideoRateControl));  
    22. memset(trt__GetVideoEncoderConfigurationResponse->Configuration->RateControl, 0, sizeof(struct tt__VideoRateControl));  
    23. //请求的对应的编码信息.各个意思参考上面说明  
    24. trt__GetVideoEncoderConfigurationResponse->Configuration->RateControl->FrameRateLimit   = 30;  
    25. trt__GetVideoEncoderConfigurationResponse->Configuration->RateControl->EncodingInterval = 1;  
    26. trt__GetVideoEncoderConfigurationResponse->Configuration->RateControl->BitrateLimit     =2048;  
    27.   
    28. trt__GetVideoEncoderConfigurationResponse->Configuration->H264 = (struct tt__H264Configuration *)soap_malloc(soap, sizeof(struct tt__H264Configuration));  
    29. memset(trt__GetVideoEncoderConfigurationResponse->Configuration->H264, 0, sizeof(struct tt__H264Configuration));  
    30. trt__GetVideoEncoderConfigurationResponse->Configuration->H264->GovLength  = 30;  
    31. trt__GetVideoEncoderConfigurationResponse->Configuration->H264->H264Profile = (enum tt__H264Profile)3;  

      (2)__trt__GetVideoEncoderConfigurations函数接口一些主要信息   

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Name = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);           
    2. memset(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Name, '', sizeof(char)*MAX_PROF_TOKEN);  
    3. strcpy(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Name, "test_vsname");  
    4.       
    5. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].token = (char *)soap_malloc(soap, sizeof(char)*MAX_PROF_TOKEN);  
    6. memset(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].token, '', sizeof(char)*MAX_PROF_TOKEN);   
    7. //请求的token值  
    8. strcpy(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].token, "test_vstoken");  
    9.                            
    10. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].UseCount = 1;  
    11. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Quality = 100;  
    12. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Encoding = (enum tt__VideoEncoding) 2;   // JPEG = 0 , MPEG = 1, H264 = 2;        
    13.   
    14. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Resolution = (struct tt__VideoResolution *)soap_malloc(soap,sizeof(struct tt__VideoResolution));  
    15. memset(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Resolution, 0 , sizeof(struct tt__VideoResolution));  
    16. // 请求的视频的分辨率,对应前端设备填写对应的值,我这是1280 * 720  
    17. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Resolution->Width  = 1280;  
    18. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].Resolution->Height = 720;  
    19.   
    20. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].RateControl = (struct tt__VideoRateControl *)soap_malloc(soap, sizeof(struct tt__VideoRateControl));  
    21. memset(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].RateControl, 0, sizeof(struct tt__VideoRateControl));  
    22. //请求的视频数据的一些编码信息  
    23. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].RateControl->FrameRateLimit   = 30;  
    24. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].RateControl->EncodingInterval = 1;  
    25. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].RateControl->BitrateLimit     = 2048;  
    26.   
    27. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].H264 = (struct tt__H264Configuration *)soap_malloc(soap, sizeof(struct tt__H264Configuration));  
    28. memset(trt__GetVideoEncoderConfigurationsResponse->Configurations[0].H264, 0, sizeof(struct tt__H264Configuration));  
    29. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].H264->GovLength  = 30;  
    30. trt__GetVideoEncoderConfigurationsResponse->Configurations[0].H264->H264Profile = (enum tt__H264Profile)3;  

       (3)__trt__GetVideoSourceConfiguration需要填写的一些基本信息  

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. trt__GetVideoSourceConfigurationResponse->Configuration->UseCount = 1;  
    2. trt__GetVideoSourceConfigurationResponse->Configuration->Name = (char*)soap_malloc(soap, sizeof(char) * MAX_PROF_TOKEN);  
    3. memset(trt__GetVideoSourceConfigurationResponse->Configuration->Name, '', sizeof(char) * MAX_PROF_TOKEN);  
    4. strcpy(trt__GetVideoSourceConfigurationResponse->Configuration->Name, "test_vsname");  
    5.   
    6. trt__GetVideoSourceConfigurationResponse->Configuration->token = (char*)soap_malloc(soap, sizeof(char) * MAX_PROF_TOKEN);  
    7. memset(trt__GetVideoSourceConfigurationResponse->Configuration->token, '', sizeof(char) * MAX_PROF_TOKEN);  
    8. strcpy(trt__GetVideoSourceConfigurationResponse->Configuration->token, "test_vstoken");  
    9.   
    10. trt__GetVideoSourceConfigurationResponse->Configuration->SourceToken = (char*)soap_malloc(soap, sizeof(char) * MAX_PROF_TOKEN);  
    11. memset(trt__GetVideoSourceConfigurationResponse->Configuration->SourceToken, '', sizeof(char) * MAX_PROF_TOKEN);  
    12. strcpy(trt__GetVideoSourceConfigurationResponse->Configuration->SourceToken, "test_vstoken");  
    13.   
    14. trt__GetVideoSourceConfigurationResponse->Configuration->Bounds = (struct tt__IntRectangle *)soap_malloc(soap, sizeof(struct tt__IntRectangle));  
    15. memset(trt__GetVideoSourceConfigurationResponse->Configuration->Bounds, 0, sizeof(struct tt__IntRectangle));  
    16. trt__GetVideoSourceConfigurationResponse->Configuration->Bounds->x      = 0;  
    17. trt__GetVideoSourceConfigurationResponse->Configuration->Bounds->y      = 0;  
    18. trt__GetVideoSourceConfigurationResponse->Configuration->Bounds->width  = 1280;  
    19. trt__GetVideoSourceConfigurationResponse->Configuration->Bounds->height = 720;  

        (4)__trt__GetVideoSourceConfigurations需要填写的一些基本信息

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. trt__GetVideoSourceConfigurationsResponse->Configurations[0].UseCount = 1;  
    2. trt__GetVideoSourceConfigurationsResponse->Configurations[0].Name = (char*)soap_malloc(soap, sizeof(char) * MAX_PROF_TOKEN);  
    3. memset(trt__GetVideoSourceConfigurationsResponse->Configurations[0].Name, '', sizeof(char) * MAX_PROF_TOKEN);  
    4. strcpy(trt__GetVideoSourceConfigurationsResponse->Configurations[0].Name, "test_vsname");  
    5.   
    6. trt__GetVideoSourceConfigurationsResponse->Configurations[0].token = (char*)soap_malloc(soap, sizeof(char) * MAX_PROF_TOKEN);  
    7. memset(trt__GetVideoSourceConfigurationsResponse->Configurations[0].token, '', sizeof(char) * MAX_PROF_TOKEN);  
    8. strcpy(trt__GetVideoSourceConfigurationsResponse->Configurations[0].token, "test_vstoken");  
    9.   
    10. trt__GetVideoSourceConfigurationsResponse->Configurations[0].SourceToken = (char*)soap_malloc(soap, sizeof(char) * MAX_PROF_TOKEN);  
    11. memset(trt__GetVideoSourceConfigurationsResponse->Configurations[0].SourceToken, '', sizeof(char) * MAX_PROF_TOKEN);  
    12. strcpy(trt__GetVideoSourceConfigurationsResponse->Configurations[0].SourceToken, "test_vstoken");  
    13.   
    14. trt__GetVideoSourceConfigurationsResponse->Configurations[0].Bounds = (struct tt__IntRectangle *)soap_malloc(soap, sizeof(struct tt__IntRectangle));  
    15. memset(trt__GetVideoSourceConfigurationsResponse->Configurations[0].Bounds, 0, sizeof(struct tt__IntRectangle));  
    16. trt__GetVideoSourceConfigurationsResponse->Configurations[0].Bounds->x      = 0;  
    17. trt__GetVideoSourceConfigurationsResponse->Configurations[0].Bounds->y      = 0;  
    18. trt__GetVideoSourceConfigurationsResponse->Configurations[0].Bounds->width  = 1280;  
    19. trt__GetVideoSourceConfigurationsResponse->Configurations[0].Bounds->height = 720;  

    这里里面本来都是一些个不相同的,通过对应不同的Token值来获取不同的视频源以及视频编码的一些信息的,因为这里我只是一个简单的测试,所以都是对单一的视频码流填写的相关信息,可能大家看到很多地方类似的,但是当不同的token值过来的时候,需要对应填写不同的相关信息的, 每次获取的时候都需要对应的判断token值是否正确,我这里都作了一些简化,在实际开发的时候都需要填充进去

    5 __trt__GetStreamUri后去设备的URi,通过RTSP获取视频流
     

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. trt__GetStreamUriResponse->MediaUri = (struct tt__MediaUri *)soap_malloc(soap, sizeof(struct tt__MediaUri));  
    2. memset(trt__GetStreamUriResponse->MediaUri, 0, sizeof(struct tt__MediaUri));  
    3.   
    4. trt__GetStreamUriResponse->MediaUri->Uri = (char *)soap_malloc(soap, sizeof(char) * MAX_64_LEN);  
    5. memset(trt__GetStreamUriResponse->MediaUri->Uri, '', sizeof(char) * MAX_64_LEN);  
    6. //根据各个设备的rtsp协议的uri不同填写对应的值  
    7. strncpy(trt__GetStreamUriResponse->MediaUri->Uri, "rtsp://192.168.12.135:554/livestream", MAX_64_LEN);  
    8. trt__GetStreamUriResponse->MediaUri->InvalidAfterConnect = (enum xsd__boolean)0;  
    9. trt__GetStreamUriResponse->MediaUri->InvalidAfterReboot  = (enum xsd__boolean)0;  
    10. //超时时间  
    11. trt__GetStreamUriResponse->MediaUri->Timeout = 200;  

    设备端通过Onvif协议来实现RTSP预览的代码已经基本写完,现在可以看看效果,首先确定设备端能够通过vlc正确预览图像, 也就是说设备端需要支持RTSP协议,

    可能通过Live555来实现。然后就可以通过onvif的工具 Onvif  Deviece Manager 来查看效果了!

     先看看Live Video的效果

      z

    再看看Video Stream的效果图

     最后看看token的一些显示的基本信息

    里面因为是自己的一些token和name信息,所以我就打了码,这是都是可以根据自己的设备自己来定的,所以对对接视频没有响,只要在请求的时候对应自己的设备的能力值获取的时候对应起来就可以的!onvif设备端对接视频流也就完成!

     

    这个过程中还是有很多不不懂的地方,可能上面的开发过程很多不够完善的地方,如果有懂的更多这方面知识的开发者,
    希望能指出我的不足或者提出自己的观点,大家相互促进学习。

  • 相关阅读:
    C/C++知识点收集
    JAVA相关知识点理解
    Windows相关收集
    【原创】java的反射机制
    【原创】如何配置声明书事务
    【原创】spring中的事务传播特性
    【摘录】JAVA内存管理-自动选择垃圾收集器算法
    【摘录】JAVA内存管理-JVM垃圾收集机制
    【摘录】数据库拆分的一般方法和原则
    【摘录】JAVA内存管理-有关垃圾收集的关键参数
  • 原文地址:https://www.cnblogs.com/lidabo/p/6604848.html
Copyright © 2011-2022 走看看