#include <iostream>
#include "ANSONVIF.h"
#include "ANSOpenCV.h"
int OnvifTest() {
	ANSCENTER::ANSOnvifClient* infHandle;
	std::vector<std::string> profileList;
	CreateANSOnvifHandle(&infHandle, "");
	SearchANSOnvifSpecificProfiles(&infHandle, "192.168.1.87", 8000, "admin", "admin123", profileList);
	for (int i = 0; i < profileList.size(); i++) {
		std::cout << "Profile:" << profileList.at(i) << std::endl;
	}
	ReleaseANSOnvifHandle(&infHandle);

	std::cout << "Hello World!\n";
}
int OnvifSearchDevicesTest() {
	ANSCENTER::ANSOnvifClient* infHandle;
	std::vector<std::string> deviceList;
	CreateANSOnvifHandle(&infHandle, "");
	std::cout << "Start searching devices on the network. Please wait..." << std::endl;
	for (int j = 0; j < 1; j++) {
		sleep(1);//sleep for 1 second
		int result = SearchANSOnvifDevices(&infHandle, 30,deviceList);
		if (deviceList.size() > 0) {
			for (int i = 0; i < deviceList.size(); i++) {
				std::cout << "Device [" << i << "] address: " << deviceList.at(i) << std::endl;
			}
		}
		std::cout << "Search device procedure is done." << std::endl;
	}
	std::vector<std::string> profileList;

	SearchANSOnvifSpecificProfiles(&infHandle, "192.168.1.87", 8000, "admin", "admin123", profileList);
	for (int i = 0; i < profileList.size(); i++) {
		std::cout << "Profile:" << profileList.at(i) << std::endl;
	}

	std::cout << "Start searching devices on the network. Please wait..." << std::endl;
	for (int j = 0; j < 1; j++) {
		sleep(1);//sleep for 1 second
		int result = SearchANSOnvifDevices(&infHandle, 15,deviceList);
		if (deviceList.size() > 0) {
			for (int i = 0; i < deviceList.size(); i++) {
				std::cout << "Device [" << i << "] address: " << deviceList.at(i) << std::endl;
			}
		}
		std::cout << "Search device procedure is done." << std::endl;
	}

	ReleaseANSOnvifHandle(&infHandle);
	return 0;
}
int main()
{
	ANSCENTER::ANSOPENCV::InitCameraNetwork();


	OnvifSearchDevicesTest();
	OnvifTest();
	return 0;

	ANSCENTER::ANSOPENCV::DeinitCameraNetwork();

}

