]> git.sesse.net Git - casparcg/blobdiff - modules/flash/producer/flash_producer.cpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / modules / flash / producer / flash_producer.cpp
index a93e70f08784c6e5efc6f081e67b715a30bc0e8a..c14158d2b21ebc2dd83b4a9db5bfeb62c39b5da1 100644 (file)
@@ -44,6 +44,7 @@
 #include <boost/filesystem.hpp>\r
 #include <boost/thread.hpp>\r
 #include <boost/timer.hpp>\r
+#include <boost/algorithm/string.hpp>\r
 \r
 #include <functional>\r
 \r
@@ -95,32 +96,48 @@ struct template_host
 \r
 template_host get_template_host(const core::video_format_desc& desc)\r
 {\r
-       std::vector<template_host> template_hosts;\r
-       BOOST_FOREACH(auto& xml_mapping, env::properties().get_child("configuration.producers.template-hosts"))\r
+       try\r
        {\r
-               try\r
+               std::vector<template_host> template_hosts;\r
+               BOOST_FOREACH(auto& xml_mapping, env::properties().get_child("configuration.producers.template-hosts"))\r
                {\r
-                       template_host template_host;\r
-                       template_host.field_mode                = xml_mapping.second.get("video-mode", narrow(desc.name));\r
-                       template_host.filename                  = xml_mapping.second.get("filename", "cg.fth");\r
-                       template_host.width                             = xml_mapping.second.get("width", desc.width);\r
-                       template_host.height                    = xml_mapping.second.get("height", desc.height);\r
-                       template_hosts.push_back(template_host);\r
+                       try\r
+                       {\r
+                               template_host template_host;\r
+                               template_host.field_mode                = xml_mapping.second.get("video-mode", narrow(desc.name));\r
+                               template_host.filename                  = xml_mapping.second.get("filename", "cg.fth");\r
+                               template_host.width                             = xml_mapping.second.get("width", desc.width);\r
+                               template_host.height                    = xml_mapping.second.get("height", desc.height);\r
+                               template_hosts.push_back(template_host);\r
+                       }\r
+                       catch(...){}\r
                }\r
-               catch(...){}\r
-       }\r
 \r
-       auto template_host_it = boost::find_if(template_hosts, [&](template_host template_host){return template_host.field_mode == narrow(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.field_mode == "";});\r
+               auto template_host_it = boost::find_if(template_hosts, [&](template_host template_host){return template_host.field_mode == narrow(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.field_mode == "";});\r
 \r
-       if(template_host_it != template_hosts.end())\r
-               return *template_host_it;\r
-       \r
+               if(template_host_it != template_hosts.end())\r
+                       return *template_host_it;\r
+       }\r
+       catch(...)\r
+       {\r
+       }\r
+               \r
        template_host template_host;\r
        template_host.filename = "cg.fth";\r
-       template_host.width = desc.width;\r
-       template_host.height = desc.height;\r
+\r
+       for(auto it = boost::filesystem2::wdirectory_iterator(env::template_folder()); it != boost::filesystem2::wdirectory_iterator(); ++it)\r
+       {\r
+               if(boost::iequals(it->path().extension(), L"." + desc.name))\r
+               {\r
+                       template_host.filename = narrow(it->filename());\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
@@ -261,7 +278,7 @@ struct flash_producer : public core::frame_producer
 \r
        tbb::atomic<int> fps_;\r
 \r
-       std::shared_ptr<diagnostics::graph> graph_;\r
+       safe_ptr<diagnostics::graph> graph_;\r
 \r
        tbb::concurrent_bounded_queue<safe_ptr<core::basic_frame>> frame_buffer_;\r
 \r
@@ -286,9 +303,10 @@ public:
 \r
                fps_ = 0;\r
 \r
-               graph_ = diagnostics::create_graph(narrow(print()));\r
                graph_->set_color("output-buffer-count", diagnostics::color(1.0f, 1.0f, 0.0f));          \r
                graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));   \r
+               graph_->set_text(print());\r
+               diagnostics::register_graph(graph_);\r
                \r
                frame_buffer_.set_capacity(frame_factory_->get_video_format_desc().fps > 30.0 ? 2 : 1);\r
 \r
@@ -402,7 +420,7 @@ public:
 \r
                                graph_->set_value("output-buffer-count", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));        \r
                                fps_.fetch_and_store(static_cast<int>(context_->fps()*100.0));                          \r
-                               graph_->update_text(narrow(print()));\r
+                               graph_->set_text(narrow(print()));\r
 \r
                                render(renderer);\r
                        }\r