可以根据对应的接口函数进行修改(例如:imaging、media相关的接口)。
修改方法:
- 获取要修改的参数
每个设置函数均有对应的获取配置函数,为了不造成系统内存错误,应先用对应的获取函数获取配置信息。
- 修改参数
这一步是直接用获取到的参数,只需要修改部分你想修改参数即可,不涉及到内存的分配。
- 将修改后的参数用设置函数写入至摄像机
这一步则是调用设置函数,将修改后的参数写入设备。
示例代码如下:
int ONVIF_IMG_SetImagingSettings(char *pcImagingXAddr, char *ProfileToken, struct _imagingSettings * pstru_ImgSettingRsu)
{
int result = 0;
struct soap *soap = NULL;
struct _timg__GetImagingSettings reqG;
struct _timg__GetImagingSettingsResponse repG;
struct _timg__SetImagingSettings reqS;
struct _timg__SetImagingSettingsResponse repS;
enum xsd__boolean ForceStorage;
SOAP_ASSERT(NULL != pcImagingXAddr);
SOAP_ASSERT(NULL != ProfileToken);
SOAP_ASSERT(NULL != pstru_ImgSettingRsu);
SOAP_ASSERT(NULL != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT)));
memset(&reqS, 0x00, sizeof(struct _timg__SetImagingSettings));
memset(&repS, 0x00, sizeof(struct _timg__SetImagingSettingsResponse));
memset(&reqG, 0x00, sizeof(struct _timg__SetImagingSettings));
memset(&repG, 0x00, sizeof(struct _timg__SetImagingSettingsResponse));
//获取系统原来的配置
reqG.VideoSourceToken = ProfileToken;
ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); //鉴权
result = soap_call___timg__GetImagingSettings(soap, pcImagingXAddr, NULL, &reqG, &repG);
SOAP_CHECK_ERROR(result, soap, "GetImagingSettings");
//修改某些参数写入设备
reqS.VideoSourceToken = ProfileToken;
reqS.ForcePersistence = &ForceStorage;
*reqS.ForcePersistence = pstru_ImgSettingRsu->ForceStorage;
reqS.ImagingSettings = repG.ImagingSettings;
*reqS.ImagingSettings->Brightness = pstru_ImgSettingRsu->Brightness;
*reqS.ImagingSettings->ColorSaturation = pstru_ImgSettingRsu->ColorSaturation;
*reqS.ImagingSettings->Contrast = pstru_ImgSettingRsu->Contrast;
reqS.ImagingSettings->Focus->AutoFocusMode = pstru_ImgSettingRsu->FocusMode;
ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); //鉴权
result = soap_call___timg__SetImagingSettings(soap, pcImagingXAddr, NULL, &reqS, &repS);
SOAP_CHECK_ERROR(result, soap, "SetImagingSettings");
EXIT:
if (NULL != soap) {
ONVIF_soap_delete(soap);
}
return result;
}
main函数调用
//修改一些参数
gstru_ImgSetting.ForceStorage = xsd__boolean__true_;
gstru_ImgSetting.FocusMode = (enum tt__AutoFocusMode)fSpeed;//auto
ONVIF_IMG_SetImagingSettings(gstru_CapaAddr.caImagingAddr, gstru_CapaAddr.caMainVideoSourceToken, &gstru_ImgSetting);
以上示例代码实现了通过onvif协议修改摄像头的AutoFocusMode(对焦模式)、Brightness(亮度)、ColorSaturation( {MOD}彩饱和度)、Contrast(饱和度)等参数。