]> git.sesse.net Git - casparcg/commitdiff
2.0. - Per video-mode template-host configuration.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 11 Aug 2011 09:58:43 +0000 (09:58 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 11 Aug 2011 09:58:43 +0000 (09:58 +0000)
     - SET MODE now clear channels.

git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1140 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/video_channel.cpp
modules/ffmpeg/producer/frame_muxer.cpp
modules/flash/producer/cg_producer.cpp
modules/flash/producer/flash_producer.cpp
shell/casparcg.config

index 3aac12736360384cf6a904a3ded913af5849f4d3..8f8d51c8835c42ea4ab66cfd0c157bbd5337dbdd 100644 (file)
@@ -122,6 +122,7 @@ public:
        {\r
                context_.execution().begin_invoke([=]\r
                {\r
+                       stage_->clear();\r
                        context_.set_format_desc(format_desc);\r
                });\r
        }\r
index d4369f73470b9d158445ab018471b9642df080b5..5402e8e29ac2054e888c26e123c39020f512afa8 100644 (file)
@@ -144,7 +144,7 @@ struct frame_muxer::implementation : boost::noncopyable
                , display_mode_(display_mode::invalid)\r
                , in_fps_(in_fps)\r
                , format_desc_(frame_factory->get_video_format_desc())\r
-               , auto_mode_(env::properties().get("configuration.producers.auto-mode", false))\r
+               , auto_mode_(env::properties().get("configuration.producers.auto-transcode", false))\r
                , audio_sample_count_(0)\r
                , video_frame_count_(0)\r
                , frame_factory_(frame_factory)\r
index 14932d56e89486ea23583b959f578060577d2ec7..42a7af2953a1b3b6032a94d09b91623f72db982d 100644 (file)
@@ -108,24 +108,6 @@ public:
                return flash_producer_->print();\r
        }\r
 };\r
-\r
-std::vector<std::wstring> template_host_params()\r
-{\r
-       std::vector<std::wstring> params;\r
-       params.push_back(widen(env::properties().get("configuration.template-host.filename", "cg.fth")));\r
-       \r
-       try\r
-       {\r
-               params.push_back(widen(env::properties().get<std::string>("configuration.template-host.width")));\r
-               params.push_back(widen(env::properties().get<std::string>("configuration.template-host.height")));\r
-       }\r
-       catch(...)\r
-       {\r
-               params.clear();\r
-               params.push_back(widen(env::properties().get("configuration.template-host.filename", "cg.fth")));\r
-       }\r
-       return params;\r
-}\r
        \r
 safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<core::video_channel>& video_channel, int render_layer)\r
 {      \r
@@ -133,7 +115,7 @@ safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<core::video_channel
 \r
        if(flash_producer->print().find(L"flash[") == std::string::npos) // UGLY hack\r
        {\r
-               flash_producer = create_flash_producer(video_channel->mixer(), template_host_params()); \r
+               flash_producer = create_flash_producer(video_channel->mixer(), boost::assign::list_of<std::wstring>()); \r
                video_channel->stage()->load(render_layer, flash_producer); \r
                video_channel->stage()->play(render_layer);\r
        }\r
@@ -147,7 +129,7 @@ safe_ptr<core::frame_producer> create_ct_producer(const safe_ptr<core::frame_fac
        if(!boost::filesystem::exists(filename))\r
                return core::frame_producer::empty();\r
        \r
-       auto flash_producer = create_flash_producer(frame_factory, template_host_params());     \r
+       auto flash_producer = create_flash_producer(frame_factory, boost::assign::list_of<std::wstring>());     \r
        auto producer = make_safe<cg_producer>(flash_producer);\r
        producer->add(0, filename, 1);\r
 \r
index 2afaf13c5627910faf41d18c9a058f42b356a9d8..aa21c1232e91d194277032cce17109baf0417e82 100644 (file)
@@ -83,6 +83,45 @@ private:
        std::shared_ptr<void> bmp_;\r
 };\r
 \r
+struct template_host\r
+{\r
+       std::string  video_mode;\r
+       std::string  filename;\r
+       size_t           width;\r
+       size_t           height;\r
+};\r
+\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
+       {\r
+               try\r
+               {\r
+                       template_host template_host;\r
+                       template_host.video_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
+\r
+       auto template_host_it = boost::find_if(template_hosts, [&](template_host template_host){return template_host.video_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.video_mode == "";});\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
+       template_host.height = desc.height;\r
+       return template_host;\r
+}\r
+\r
 class flash_renderer\r
 {      \r
        const std::wstring filename_;\r
@@ -144,7 +183,7 @@ public:
                ax_->SetSize(width_, height_);          \r
        \r
                CASPAR_LOG(info) << print() << L" Thread started.";\r
-               CASPAR_LOG(info) << print() << L" Successfully initialized to, width: " << width_ << L" height: " << height_ << L".";\r
+               CASPAR_LOG(info) << print() << L" Successfully initialized with template-host: " << filename << L" width: " << width_ << L" height: " << height_ << L".";\r
        }\r
 \r
        ~flash_renderer()\r
@@ -166,13 +205,6 @@ public:
        \r
        safe_ptr<core::basic_frame> render_frame(bool has_underflow)\r
        {\r
-               //if(format_desc_ != frame_factory_->get_video_format_desc())\r
-               //{\r
-               //      format_desc_ = frame_factory_->get_video_format_desc();\r
-               //      bmp_ = bitmap(format_desc_.width, format_desc_.height);\r
-               //      ax_->SetFormat(format_desc_);\r
-               //}\r
-\r
                float frame_time = 1.0f/ax_->GetFPS();\r
 \r
                graph_->update_value("tick-time", static_cast<float>(tick_timer_.elapsed()/frame_time)*0.5f);\r
@@ -288,9 +320,9 @@ public:
                        {\r
                                context_->param(param); \r
 \r
-                               const auto& format_desc = frame_factory_->get_video_format_desc();\r
-                               if(abs(context_->fps() - format_desc.fps) > 0.01 && abs(context_->fps()/2.0 - format_desc.fps) > 0.01)\r
-                                       CASPAR_LOG(warning) << print() << " Invalid frame-rate: " << context_->fps() << L". Should be either " << format_desc.fps << L" or " << format_desc.fps*2.0 << L".";\r
+                               //const auto& format_desc = frame_factory_->get_video_format_desc();\r
+                               //if(abs(context_->fps() - format_desc.fps) > 0.01 && abs(context_->fps()/2.0 - format_desc.fps) > 0.01)\r
+                               //      CASPAR_LOG(warning) << print() << " Invalid frame-rate: " << context_->fps() << L". Should be either " << format_desc.fps << L" or " << format_desc.fps*2.0 << L".";\r
                        }\r
                        catch(...)\r
                        {\r
@@ -362,18 +394,9 @@ public:
 \r
 safe_ptr<core::frame_producer> create_flash_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
 {\r
-       std::wstring filename = env::template_folder() + L"\\" + params[0];\r
-\r
-       size_t width = frame_factory->get_video_format_desc().width;\r
-       size_t height = frame_factory->get_video_format_desc().height;\r
-\r
-       if(params.size() >= 3)\r
-       {\r
-               width = boost::lexical_cast<size_t>(params[1]);\r
-               height = boost::lexical_cast<size_t>(params[2]);\r
-       }\r
+       auto template_host = get_template_host(frame_factory->get_video_format_desc());\r
        \r
-       return make_safe<flash_producer>(frame_factory, filename, width, height);\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
index df63dc8be25be4d6b5b62dd040dcab858ad80e27..91558aba70391cd437ab656106fc3e08fff493cd 100644 (file)
@@ -9,16 +9,27 @@
   <diagnostics>\r
     <graphs>true</graphs>\r
   </diagnostics>\r
-  <template-host>\r
-    <filename>cg.fth.18</filename>\r
-    <width>1280</width>\r
-    <height>720</height>\r
-  </template-host>\r
   <consumers>\r
     <buffer-depth>3</buffer-depth>\r
   </consumers>\r
   <producers>\r
-    <auto-mode>true</auto-mode>\r
+    <auto-transcode>true</auto-transcode>\r
+    <template-hosts>\r
+      <template-host>\r
+        <video-mode>1080p5000</video-mode>\r
+        <filename>cg.fth.18</filename>\r
+        <width>1280</width>\r
+        <height>720</height>\r
+      </template-host>\r
+      <template-host>\r
+        <video-mode>PAL</video-mode>\r
+        <filename>cg.fth.18</filename>\r
+      </template-host>\r
+      <template-host>\r
+        <video-mode>NTSC</video-mode>\r
+        <filename>cg.fth.18</filename>\r
+      </template-host>\r
+    </template-hosts>\r
   </producers>\r
   <channels>\r
     <channel>\r
@@ -29,6 +40,9 @@
           <embedded-audio>true</embedded-audio>\r
           <low-latency>true</low-latency>\r
         </decklink>\r
+        <screen>\r
+          <device>1</device>\r
+        </screen>\r
       </consumers>\r
     </channel>\r
 </channels>\r