#include "XNetSDKTest.h"
#include "XNetSDKSyn.h"
#include "AVEnc_VideoColor.h"

USE_NS_NETSDK_CFG

int TestVideoCfg()
{
	printf("%s\r\n", __FUNCTION__);
	char c = 0;
	while((c = getchar()) != 'q')
	{
		switch(c)
		{
		case 'g':
			{
				char szOutBuf[40960] = {0};
				int nInOutBufLen = sizeof(szOutBuf);
				char outbuffer[100] = {0};
				int len = 0;
				int nGetCfg = XSDK_DevGetChnConfigSyn(g_hDevice, 0, JK_AVEnc_VideoColor, szOutBuf, &nInOutBufLen, 4000, EXCMD_CONFIG_GET);
				
				if (nGetCfg >= 0 && nInOutBufLen > 0)
				{
					JObjArrayObject<AVEnc_VideoColor> cfg(NULL, "AVEnc.VideoColor.[0]");
					cfg.Parse(szOutBuf);
					if(cfg.objs.Size() > 0)
					{
						printf("Enable = %d\r\n", cfg.objs[0].Enable.Value());
						cfg.objs[0].m_VideoColorParam.Brightness.SetValue(50);

						const char *pCfg = cfg.ToString();
						
						nGetCfg = XSDK_DevSetChnConfigSyn(g_hDevice, 0, JK_AVEnc_VideoColor, pCfg, strlen(pCfg), outbuffer, &len, 5000, EXCMD_CONFIG_SET);
						
						if(nGetCfg >= 0)
						{
							printf("Set Success!\r\n");
						}
					}
				}
			}
			break;
		}
	}
	return 0;
}


