首页 > 代码库 > Onvif 获取指定通道的流媒体地址

Onvif 获取指定通道的流媒体地址

GetStreamUri函数可以获取流媒体地址。
代码如下:
void UserGetUri(const char* xAddr)
{
  int result=0 ;
  struct soap *soap = soap_new();
  struct _trt__GetStreamUri trt__GetStreamUri ;
  struct _trt__GetStreamUriResponse trt__GetStreamUriResponse;
  printf("\n\n---------------Getting Uri----------------\n\n");

  trt__GetStreamUri.StreamSetup = (struct tt__StreamSetup *)soap_malloc(soap, sizeof(struct tt__StreamSetup));
  trt__GetStreamUri.StreamSetup->__any = NULL;
  trt__GetStreamUri.StreamSetup->__anyAttribute = NULL;
  trt__GetStreamUri.StreamSetup->__size = 1;
  trt__GetStreamUri.StreamSetup->Stream = tt__StreamType__RTP_Unicast;
  trt__GetStreamUri.StreamSetup->Transport = (struct tt__Transport *)soap_malloc(soap,sizeof(struct tt__Transport));
  trt__GetStreamUri.StreamSetup->Transport->Protocol = tt__TransportProtocol__UDP;
  trt__GetStreamUri.StreamSetup->Transport->Tunnel = NULL;
  trt__GetStreamUri.ProfileToken = soap_malloc(soap, 1024);
  strcpy(trt__GetStreamUri.ProfileToken , "Token_000"); //指明哪一通道的流媒体地址
  soap_call___trt__GetStreamUri(soap, xAddr, NULL, &trt__GetStreamUri, &trt__GetStreamUriResponse);

  if (soap->error)
  {
    printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
    result = soap->error;

  }

  else
  {
    printf("!!!!NOTE: RTSP Addr Get Done is :%s \n",trt__GetStreamUriResponse.MediaUri->Uri);
  }

}