2016-12-09 1 views
1

gSOAP을 사용하여 ONVIF 호환 카메라를 구성하고 있습니다. 현재 요청에서 모든 매개 변수를 수동으로 설정하고 있습니다. 이것은 SetVideEncoderConfigurationgSOAP 요청/응답에 값을 설정하거나 가져 오는 더 쉬운 방법이 있습니까?

MediaBindingProxy mediaDevice (uri); 
AUTHENTICATE (mediaDevice); 
_trt__SetVideoEncoderConfiguration req; 
_trt__SetVideoEncoderConfigurationResponse resp; 
struct tt__VideoEncoderConfiguration encoderConfig; 
struct tt__VideoResolution resolutionConfig; 
encoderConfig.Name = strdup (name); 
encoderConfig.UseCount = 1; 
encoderConfig.Quality = 50; 

if (strcmp (encoding, "H264") == 0) 
encoderConfig.Encoding = tt__VideoEncoding__H264; 
else if (strcmp (encoding, "JPEG") == 0) 
encoderConfig.Encoding = tt__VideoEncoding__JPEG; 

encoderConfig.token = strdup (profileToken); 
encoderConfig.SessionTimeout = (LONG64)"PT0S"; 
resolutionConfig.Width=1280; 
resolutionConfig.Height=720; 
encoderConfig.Resolution = &resolutionConfig; 
tt__VideoRateControl rateControl; 
rateControl.FrameRateLimit = 15; 
rateControl.EncodingInterval = 1; 
rateControl.BitrateLimit = 4500; 
encoderConfig.RateControl = &rateControl; 
struct tt__H264Configuration h264; 
h264.GovLength = 30; 
h264.H264Profile = tt__H264Profile__Baseline; 
encoderConfig.H264 = &h264; 

struct tt__MulticastConfiguration multicast; 
struct tt__IPAddress address; 
address.IPv4Address = strdup ("0.0.0.0"); 
multicast.Address = &address; 

encoderConfig.Multicast = &multicast; 

req.Configuration = &encoderConfig; 
req.ForcePersistence = true; 



int ret = mediaDevice.SetVideoEncoderConfiguration (&req, resp); 
qDebug() << "Set Encoder: " << ret; 

이 작업을 수행하는 쉬운 방법이 있나요입니다? 요청 매개 변수를 설정하는 함수 호출이있을 수 있습니까? 내가 GetMediaUri 발견하는 또 다른 방법은

soap_new_req__trt__GetStreamUri (mediaDevice.soap,soap_new_req_tt__StreamSetup (mediaDevice.soap, (enum tt__StreamType)0, soap_new_tt__Transport(mediaDevice.soap), 1, NULL), "profile1"); 

같은 것을 사용하는 것이 었습니다 이러한 gSOAP와 클라이언트 측 코드에 대한 두 가지 방법이 있습니까?

-Mandar 조시

+0

메모리 누수에주의하십시오.'stapdup'가 아닌'soap_malloc'을 사용하여 문자열을 할당해야합니다. – mpromonet

답변

2

gSOAP와 C++를 입력 T의 데이터를 할당 할 soap_new_T()의 네 가지 변화가 있습니다

  • T * soap_new_T(struct soap*) 온 초기화와 할당 된 기본 입니다 T의 새로운 인스턴스가 반환은 힙은 soap 컨텍스트로 관리됩니다.
  • T * soap_new_T(struct soap*, int n)T의 새 인스턴스 n의 배열을 관리 힙에 반환합니다. 배열의 인스턴스는 위에서 설명한대로 기본적으로 초기화됩니다.
  • T * soap_new_req_T(struct soap*, ...) (구조체와 클래스 만)는 관리 힙에 할당 T의 새로운 인스턴스를 반환하고 다른 인수 ...에 지정된 값에 필요한 데이터 멤버를 설정합니다.
  • T * soap_new_set_T(struct soap*, ...) (구조체와 클래스 만)는 관리 힙에 T의 새로운 인스턴스를 반환하고 다른 인수 ...에 지정된 값으로 공공/직렬화 데이터 멤버를 설정합니다.

strdup 대신 soap_strdup(struct soap*, const char*)을 사용하면 관리되는 힙에 문자열을 덤프 할 수 있습니다. 관리되는 힙에

모든 데이터는 대량 삭제 soap_destroy(soap)soap_end(soap)로 (즉, 순서대로 전화) soap_done(soap) 또는 soap_free(soap) 전에 호출해야합니다.

데이터 사용 템플릿에 대한 포인터를 할당하려면 :

template<class T> 
T * soap_make(struct soap *soap, T val) 
{ 
    T *p = (T*)soap_malloc(soap, sizeof(T)); 
    if (p) 
    *p = val; 
    return p; 
} 
template<class T> 
T **soap_make_array(struct soap *soap, T* array, int n) 
{ 
    T **p = (T**)soap_malloc(soap, n * sizeof(T*)); 
    for (int i = 0; i < n; ++i) 
    p[i] = &array[i]; 
    return p; 
} 

그런 다음 관리되는 힙에 값 123에 대한 포인터를 만들 soap_make<int>(soap, 123)를 사용 soap_make_array(soap, soap_new_CLASSNAME(soap, 100), 100)CLASSNAME 100 개 인스턴스 (100) 포인터를 만들 수 있습니다.

gSOAP 도구는 또한 사용자를 위해 완전 복사 작업을 생성합니다. CLASSNAME::soap_dup(struct soap*)은 개체의 전체 복사본을 만들고 사용자가 인수로 제공하는 다른 soap 컨텍스트에 할당합니다. 관리되지 않는 전체 복사본을 할당하려면이 인수로 NULL을 사용합니다 (그러나 포인터 사이클을 사용할 수 없습니다!). 그런 다음 CLASSNAME::soap_del()으로 관리되지 않는 복사본을 삭제하여 모든 구성원을 완전 삭제 한 다음 개체 자체를 delete 삭제하십시오.

자세한 내용은 Memory management in C++을 참조하십시오. gSOAP 2.8.39 이상을 사용하십시오.

관련 문제