#include #include #include #include "capabilities/capa.h" #include "proto_comm.h" #include "proto_dbg.h" /************************************************************************ * Get the video and audio configurations * [in] MediaXAddr: the media service address [out] profiles: the parsed cfg data and it should be freed by the customer after finished * ************************************************************************/ int proto_GetProfiles(const char *MediaXAddr, struct tagProfile **profiles, const char *username, const char *passwd) { int i = 0; int result = 0; struct soap *soap = NULL; struct _trt__GetProfiles req; struct _trt__GetProfilesResponse rep; SOAP_ASSERT(NULL != MediaXAddr); SOAP_ASSERT(NULL != (soap = proto_soap_new(SOAP_SOCK_TIMEOUT))); proto_SetAuthInfo(soap, username, passwd); memset(&req, 0x00, sizeof(req)); memset(&rep, 0x00, sizeof(rep)); result = soap_call___trt__GetProfiles(soap, MediaXAddr, NULL, &req, &rep); SOAP_CHECK_ERROR(result, soap, "GetProfiles"); dump_trt__GetProfilesResponse(&rep); if (rep.__sizeProfiles > 0) { (*profiles) = (struct tagProfile *)malloc(rep.__sizeProfiles * sizeof(struct tagProfile)); SOAP_ASSERT(NULL != (*profiles)); memset((*profiles), 0x00, rep.__sizeProfiles * sizeof(struct tagProfile)); } for(i = 0; i < rep.__sizeProfiles; i++) { struct tt__Profile *ttProfile = &rep.Profiles[i]; struct tagProfile *plst = &(*profiles)[i]; if (NULL != ttProfile->token) { strncpy(plst->token, ttProfile->token, sizeof(plst->token) - 1); } if (NULL != ttProfile->VideoSourceConfiguration) { struct tt__VideoSourceConfiguration *vsc = ttProfile->VideoSourceConfiguration; if (NULL != vsc->token) { strncpy(plst->videoCfg.token, vsc->token, sizeof(plst->videoCfg.token) - 1); } if (NULL != vsc->SourceToken) { strncpy(plst->videoCfg.sourceToken, vsc->SourceToken, sizeof(plst->videoCfg.sourceToken) - 1); } if (NULL != vsc->Bounds) { plst->videoCfg.x = vsc->Bounds->x; plst->videoCfg.y = vsc->Bounds->y; plst->videoCfg.Width = vsc->Bounds->width; plst->videoCfg.Height = vsc->Bounds->height; } } if (NULL != ttProfile->VideoEncoderConfiguration) { if (NULL != ttProfile->VideoEncoderConfiguration->token) { strncpy(plst->venc.token, ttProfile->VideoEncoderConfiguration->token, sizeof(plst->venc.token) - 1); } if (NULL != ttProfile->VideoEncoderConfiguration->Resolution) { // 视频编码器分辨率 plst->venc.Width = ttProfile->VideoEncoderConfiguration->Resolution->Width; plst->venc.Height = ttProfile->VideoEncoderConfiguration->Resolution->Height; } } } EXIT: if (NULL != soap) { proto_soap_delete(soap); } return rep.__sizeProfiles; } int proto_GetCapabilities(const char *DeviceXAddr, struct tagCapabilities *capa, const char *username, const char *passwd) { int result = 0; struct soap *soap = NULL; struct _tds__GetCapabilities req; struct _tds__GetCapabilitiesResponse rep; SOAP_ASSERT(NULL != DeviceXAddr); SOAP_ASSERT(NULL != capa); SOAP_ASSERT(NULL != (soap = proto_soap_new(SOAP_SOCK_TIMEOUT))); proto_SetAuthInfo(soap, username, passwd); memset(&req, 0x00, sizeof(req)); memset(&rep, 0x00, sizeof(rep)); result = soap_call___tds__GetCapabilities(soap, DeviceXAddr, NULL, &req, &rep); SOAP_CHECK_ERROR(result, soap, "GetCapabilities"); dump_tds__GetCapabilitiesResponse(&rep); memset(capa, 0x00, sizeof(struct tagCapabilities)); if (NULL != rep.Capabilities) { if (NULL != rep.Capabilities->Media) { if (NULL != rep.Capabilities->Media->XAddr) { strncpy(capa->MediaXAddr, rep.Capabilities->Media->XAddr, sizeof(capa->MediaXAddr) - 1); } } if (NULL != rep.Capabilities->Events) { if (NULL != rep.Capabilities->Events->XAddr) { strncpy(capa->EventXAddr, rep.Capabilities->Events->XAddr, sizeof(capa->EventXAddr) - 1); } } if (NULL != rep.Capabilities->Analytics) { if (NULL != rep.Capabilities->Analytics->XAddr) { strncpy(capa->AnalyticsXAddr, rep.Capabilities->Analytics->XAddr, sizeof(capa->AnalyticsXAddr) - 1); } } if (NULL != rep.Capabilities->Device) { if (NULL != rep.Capabilities->Device->XAddr) { strncpy(capa->DeviceXAddr, rep.Capabilities->Device->XAddr, sizeof(capa->DeviceXAddr) - 1); } } if (NULL != rep.Capabilities->Imaging) { if (NULL != rep.Capabilities->Imaging->XAddr) { strncpy(capa->ImageXAddr, rep.Capabilities->Imaging->XAddr, sizeof(capa->ImageXAddr) - 1); } } if (NULL != rep.Capabilities->PTZ) { if (NULL != rep.Capabilities->PTZ->XAddr) { strncpy(capa->PTZXAddr, rep.Capabilities->PTZ->XAddr, sizeof(capa->PTZXAddr) - 1); } } } EXIT: if (NULL != soap) { proto_soap_delete(soap); } return result; }