]> git.sesse.net Git - casparcg/blobdiff - modules/flash/producer/flash_producer.cpp
2.0.2: ct-producer uses complete path.
[casparcg] / modules / flash / producer / flash_producer.cpp
index c285ba9fcc876ab55a9843bed79fa7e899958dda..9ac975017b3b4aa683611be3aee444a7ebe42d5e 100644 (file)
@@ -49,7 +49,7 @@
 \r
 #include <tbb/spin_mutex.h>\r
 \r
-namespace caspar {\r
+namespace caspar { namespace flash {\r
                \r
 class bitmap\r
 {\r
@@ -95,28 +95,35 @@ 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
+       catch(...)\r
+       {\r
+               CASPAR_LOG(info) << L" Found no correct template-host configuration. Using cg.fth.";\r
+       }\r
 \r
-       if(template_host_it != template_hosts.end())\r
-               return *template_host_it;\r
-       \r
        template_host template_host;\r
        template_host.filename = "cg.fth";\r
        template_host.width = desc.width;\r
@@ -238,6 +245,11 @@ public:
                return head_;\r
        }\r
 \r
+       bool is_empty() const\r
+       {\r
+               return ax_->IsEmpty();\r
+       }\r
+\r
        double fps() const\r
        {\r
                return ax_->GetFPS();   \r
@@ -281,7 +293,7 @@ public:
 \r
                fps_ = 0;\r
 \r
-               graph_ = diagnostics::create_graph([this]{return print();});\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
                \r
@@ -302,7 +314,7 @@ public:
                graph_->set_value("output-buffer-count", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));\r
 \r
                auto frame = core::basic_frame::late();\r
-               if(!frame_buffer_.try_pop(frame))\r
+               if(!frame_buffer_.try_pop(frame) && context_)\r
                        graph_->add_tag("underflow");\r
 \r
                return frame;\r
@@ -389,8 +401,15 @@ public:
                                        frame_buffer_.push(frame);\r
                                }\r
 \r
+                               if(context_->is_empty())\r
+                               {\r
+                                       context_.reset(nullptr);\r
+                                       return;\r
+                               }\r
+\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
+                               fps_.fetch_and_store(static_cast<int>(context_->fps()*100.0));                          \r
+                               graph_->update_text(narrow(print()));\r
 \r
                                render(renderer);\r
                        }\r
@@ -404,14 +423,14 @@ public:
        }\r
 };\r
 \r
-safe_ptr<core::frame_producer> create_flash_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
+safe_ptr<core::frame_producer> create_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
 {\r
        auto template_host = get_template_host(frame_factory->get_video_format_desc());\r
        \r
        return make_safe<flash_producer>(frame_factory, env::template_folder() + L"\\" + widen(template_host.filename), template_host.width, template_host.height);\r
 }\r
 \r
-std::wstring find_flash_template(const std::wstring& template_name)\r
+std::wstring find_template(const std::wstring& template_name)\r
 {\r
        if(boost::filesystem::exists(template_name + L".ft")) \r
                return template_name + L".ft";\r
@@ -422,4 +441,4 @@ std::wstring find_flash_template(const std::wstring& template_name)
        return L"";\r
 }\r
 \r
-}
\ No newline at end of file
+}}
\ No newline at end of file