+struct template_host\r
+{\r
+ std::wstring video_mode;\r
+ std::wstring filename;\r
+ int width;\r
+ int height;\r
+};\r
+\r
+template_host get_template_host(const core::video_format_desc& desc)\r
+{\r
+ try\r
+ {\r
+ std::vector<template_host> template_hosts;\r
+ BOOST_FOREACH(auto& xml_mapping, env::properties().get_child(L"configuration.template-hosts"))\r
+ {\r
+ try\r
+ {\r
+ template_host template_host;\r
+ template_host.video_mode = xml_mapping.second.get(L"video-mode", L"");\r
+ template_host.filename = xml_mapping.second.get(L"filename", L"cg.fth");\r
+ template_host.width = xml_mapping.second.get(L"width", desc.width);\r
+ template_host.height = xml_mapping.second.get(L"height", desc.height);\r
+ template_hosts.push_back(template_host);\r
+ }\r
+ catch(...){}\r
+ }\r
+\r
+ auto template_host_it = boost::find_if(template_hosts, [&](template_host template_host){return template_host.video_mode == desc.name;});\r
+ if(template_host_it == template_hosts.end())\r
+ template_host_it = boost::find_if(template_hosts, [&](template_host template_host){return template_host.video_mode == L"";});\r
+\r
+ if(template_host_it != template_hosts.end())\r
+ return *template_host_it;\r
+ }\r
+ catch(...){}\r
+ \r
+ template_host template_host;\r
+ template_host.filename = L"cg.fth";\r
+\r
+ for(auto it = boost::filesystem::directory_iterator(env::template_folder()); it != boost::filesystem::directory_iterator(); ++it)\r
+ {\r
+ if(boost::iequals(it->path().extension().wstring(), L"." + desc.name))\r
+ {\r
+ template_host.filename = it->path().filename().wstring();\r
+ break;\r
+ }\r
+ }\r
+\r
+ template_host.width = desc.square_width;\r
+ template_host.height = desc.square_height;\r
+ return template_host;\r
+}\r
+\r