]> git.sesse.net Git - casparcg/commitdiff
* Refactored so that frame_producers are stored in a frame_producer_registry instance...
authorHelge Norberg <helge.norberg@svt.se>
Wed, 1 Jul 2015 12:09:35 +0000 (14:09 +0200)
committerHelge Norberg <helge.norberg@svt.se>
Wed, 1 Jul 2015 12:09:35 +0000 (14:09 +0200)
* Created a new executable called generate_docs which generates the relevant parts of the wiki which can be auto generated from the online help.

32 files changed:
core/CMakeLists.txt
core/fwd.h
core/help/util.cpp [new file with mode: 0644]
core/help/util.h [new file with mode: 0644]
core/module_dependencies.h
core/producer/frame_producer.cpp
core/producer/frame_producer.h
core/producer/scene/xml_scene_producer.cpp
core/producer/text/text_producer.cpp
core/producer/text/text_producer.h
core/thumbnail_generator.cpp
core/thumbnail_generator.h
modules/decklink/decklink.cpp
modules/ffmpeg/ffmpeg.cpp
modules/flash/flash.cpp
modules/html/html.cpp
modules/image/image.cpp
modules/psd/psd_scene_producer.cpp
modules/reroute/reroute.cpp
protocol/amcp/AMCPCommand.h
protocol/amcp/AMCPCommandsImpl.cpp
protocol/amcp/amcp_command_repository.cpp
protocol/amcp/amcp_command_repository.h
protocol/cii/CIIProtocolStrategy.cpp
protocol/cii/CIIProtocolStrategy.h
protocol/clk/CLKProtocolStrategy.cpp
protocol/clk/CLKProtocolStrategy.h
protocol/clk/clk_commands.cpp
protocol/clk/clk_commands.h
shell/CMakeLists.txt
shell/generate_docs.cpp [new file with mode: 0644]
shell/server.cpp

index 0738bc1719982c5f4eb4bc3258a8d1d1247fbd9e..677ec6df71325ec025ac63d5ecccf131680d0aab 100644 (file)
@@ -16,6 +16,7 @@ set(SOURCES
                frame/geometry.cpp
 
                help/help_repository.cpp
+               help/util.cpp
 
                mixer/audio/audio_mixer.cpp
                mixer/image/blend_modes.cpp
@@ -75,6 +76,7 @@ set(HEADERS
 
                help/help_repository.h
                help/help_sink.h
+               help/util.h
 
                interaction/interaction_aggregator.h
                interaction/interaction_event.h
index 6442a3dcb7bd0dc7c01ca8a7e6a4e133a4fafcb5..6a0129bcf0c4ec6ecf85802a2b61b82297f9c608 100644 (file)
@@ -48,3 +48,5 @@ FORWARD2(caspar, core, struct write_frame_consumer);
 FORWARD2(caspar, core, struct frame_producer_dependencies);
 FORWARD2(caspar, core, class help_sink);
 FORWARD2(caspar, core, class help_repository);
+FORWARD2(caspar, core, struct module_dependencies);
+FORWARD2(caspar, core, class frame_producer_registry);
diff --git a/core/help/util.cpp b/core/help/util.cpp
new file mode 100644 (file)
index 0000000..2c71445
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Helge Norberg, helge.norberg@svt.se
+*/
+
+#include "util.h"
+
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
+
+#include <list>
+#include <vector>
+#include <sstream>
+
+namespace caspar { namespace core {
+
+void wordwrap_line(const std::wstring& line, int width, std::wostream& result)
+{
+       std::list<std::wstring> words;
+       boost::split(words, line, boost::is_any_of(L" "), boost::algorithm::token_compress_on);
+
+       size_t current_width = 0;
+       bool first = true;
+
+       while (!words.empty())
+       {
+               auto word = std::move(words.front());
+               words.pop_front();
+
+               if (first)
+               {
+                       current_width = word.length();
+                       result << std::move(word);
+                       first = false;
+               }
+               else if (current_width + 1 + word.length() > width)
+               {
+                       result << L"\n";
+                       current_width = word.length();
+                       result << std::move(word);
+               }
+               else
+               {
+                       current_width += 1 + word.length();
+                       result << L" " << std::move(word);
+               }
+       }
+}
+
+std::wstring wordwrap(const std::wstring& text, int width)
+{
+       std::vector<std::wstring> lines;
+       boost::split(lines, text, boost::is_any_of(L"\n"));
+
+       std::wstringstream result;
+
+       for (auto& line : lines)
+       {
+               wordwrap_line(line, width, result);
+               result << L"\n";
+       }
+
+       return result.str();
+}
+
+std::wstring indent(std::wstring text, const std::wstring& indent)
+{
+       text.insert(0, indent);
+       bool last_is_newline = text.at(text.length() - 1) == L'\n';
+
+       if (last_is_newline)
+               text.erase(text.length() - 1);
+
+       boost::replace_all(text, L"\n", L"\n" + indent);
+
+       if (last_is_newline)
+               text += L'\n';
+
+       return text;
+}
+
+}}
diff --git a/core/help/util.h b/core/help/util.h
new file mode 100644 (file)
index 0000000..e42bd87
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Helge Norberg, helge.norberg@svt.se
+*/
+
+#pragma once
+
+#include <string>
+
+namespace caspar { namespace core {
+
+std::wstring wordwrap(const std::wstring& text, int width);
+std::wstring indent(std::wstring text, const std::wstring& indent);
+
+}}
index d37ececef9be59233b369c5a994b5d2643831192..1357e7c999838d59d2a7e6a571f6f9236dad65f8 100644 (file)
@@ -26,6 +26,7 @@
 #include "system_info_provider.h"
 #include "producer/cg_proxy.h"
 #include "producer/media_info/media_info_repository.h"
+#include "producer/frame_producer.h"
 
 namespace caspar { namespace core {
 
@@ -34,14 +35,17 @@ struct module_dependencies
        const spl::shared_ptr<system_info_provider_repository>  system_info_provider_repo;
        const spl::shared_ptr<cg_producer_registry>                             cg_registry;
        const spl::shared_ptr<media_info_repository>                    media_info_repo;
+       const spl::shared_ptr<frame_producer_registry>                  producer_registry;
 
        module_dependencies(
                        spl::shared_ptr<system_info_provider_repository> system_info_provider_repo,
                        spl::shared_ptr<cg_producer_registry> cg_registry,
-                       spl::shared_ptr<media_info_repository> media_info_repo)
+                       spl::shared_ptr<media_info_repository> media_info_repo,
+                       spl::shared_ptr<frame_producer_registry> producer_registry)
                : system_info_provider_repo(std::move(system_info_provider_repo))
                , cg_registry(std::move(cg_registry))
                , media_info_repo(std::move(media_info_repo))
+               , producer_registry(std::move(producer_registry))
        {
        }
 };
index 5cc009ad8ec053c8d9016e2ca1c52bb9ed7fde4e..384a019989b859b4e1be090a085337ace580ec12 100644 (file)
 #include <boost/thread.hpp>
 
 namespace caspar { namespace core {
-       
-std::vector<producer_factory_t> g_producer_factories;
-std::vector<producer_factory_t> g_thumbnail_factories;
 
-void register_producer_factory(const producer_factory_t& factory)
+struct frame_producer_registry::impl
+{
+       std::vector<producer_factory_t> producer_factories;
+       std::vector<producer_factory_t> thumbnail_factories;
+};
+
+frame_producer_registry::frame_producer_registry()
+    : impl_(new impl)
+{
+}
+
+void frame_producer_registry::register_producer_factory(const producer_factory_t& factory)
 {
-       g_producer_factories.push_back(factory);
+       impl_->producer_factories.push_back(factory);
 }
-void register_thumbnail_producer_factory(const producer_factory_t& factory)
+
+void frame_producer_registry::register_thumbnail_producer_factory(const producer_factory_t& factory)
 {
-       g_thumbnail_factories.push_back(factory);
+       impl_->thumbnail_factories.push_back(factory);
 }
 
 frame_producer_dependencies::frame_producer_dependencies(
                const spl::shared_ptr<core::frame_factory>& frame_factory,
                const std::vector<spl::shared_ptr<video_channel>>& channels,
-               const video_format_desc& format_desc)
+               const video_format_desc& format_desc,
+               const spl::shared_ptr<const frame_producer_registry> producer_registry)
        : frame_factory(frame_factory)
        , channels(channels)
        , format_desc(format_desc)
+       , producer_registry(producer_registry)
 {
 }
 
@@ -306,39 +317,41 @@ spl::shared_ptr<core::frame_producer> do_create_producer(const frame_producer_de
        return producer;
 }
 
-spl::shared_ptr<core::frame_producer> create_thumbnail_producer(const frame_producer_dependencies& dependencies, const std::wstring& media_file)
+spl::shared_ptr<core::frame_producer> frame_producer_registry::create_thumbnail_producer(const frame_producer_dependencies& dependencies, const std::wstring& media_file) const
 {
-  std::vector<std::wstring> params;
-  params.push_back(media_file);
+       auto& thumbnail_factories = impl_->thumbnail_factories;
+       std::vector<std::wstring> params;
+       params.push_back(media_file);
 
-  auto producer = do_create_producer(dependencies, params, g_thumbnail_factories, true);
-  auto key_producer = frame_producer::empty();
+       auto producer = do_create_producer(dependencies, params, thumbnail_factories, true);
+       auto key_producer = frame_producer::empty();
   
-  try // to find a key file.
-  {
-       auto params_copy = params;
-       if (params_copy.size() > 0)
+       try // to find a key file.
        {
-         params_copy[0] += L"_A";
-         key_producer = do_create_producer(dependencies, params_copy, g_thumbnail_factories, true);
-         if (key_producer == frame_producer::empty())
-         {
-               params_copy[0] += L"LPHA";
-               key_producer = do_create_producer(dependencies, params_copy, g_thumbnail_factories, true);
-         }
+               auto params_copy = params;
+               if (params_copy.size() > 0)
+               {
+                       params_copy[0] += L"_A";
+                       key_producer = do_create_producer(dependencies, params_copy, thumbnail_factories, true);
+                       if (key_producer == frame_producer::empty())
+                       {
+                               params_copy[0] += L"LPHA";
+                               key_producer = do_create_producer(dependencies, params_copy, thumbnail_factories, true);
+                       }
+               }
        }
-  }
-  catch(...){}
+       catch(...){}
 
-  if (producer != frame_producer::empty() && key_producer != frame_producer::empty())
-       return create_separated_producer(producer, key_producer);
+       if (producer != frame_producer::empty() && key_producer != frame_producer::empty())
+               return create_separated_producer(producer, key_producer);
   
-  return producer;
+       return producer;
 }
 
-spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies& dependencies, const std::vector<std::wstring>& params)
+spl::shared_ptr<core::frame_producer> frame_producer_registry::create_producer(const frame_producer_dependencies& dependencies, const std::vector<std::wstring>& params) const
 {      
-       auto producer = do_create_producer(dependencies, params, g_producer_factories);
+       auto& producer_factories = impl_->producer_factories;
+       auto producer = do_create_producer(dependencies, params, producer_factories);
        auto key_producer = frame_producer::empty();
        
        try // to find a key file.
@@ -347,11 +360,11 @@ spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_depen
                if(params_copy.size() > 0)
                {
                        params_copy[0] += L"_A";
-                       key_producer = do_create_producer(dependencies, params_copy, g_producer_factories);
+                       key_producer = do_create_producer(dependencies, params_copy, producer_factories);
                        if(key_producer == frame_producer::empty())
                        {
                                params_copy[0] += L"LPHA";
-                               key_producer = do_create_producer(dependencies, params_copy, g_producer_factories);
+                               key_producer = do_create_producer(dependencies, params_copy, producer_factories);
                        }
                }
        }
@@ -372,7 +385,7 @@ spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_depen
 }
 
 
-spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies& dependencies, const std::wstring& params)
+spl::shared_ptr<core::frame_producer> frame_producer_registry::create_producer(const frame_producer_dependencies& dependencies, const std::wstring& params) const
 {
        std::wstringstream iss(params);
        std::vector<std::wstring> tokens;
index 5a857d9b7f8319877dadbb9a0eb67a3ddc3572c5..c420ebf6d333d10bc3ebebddf417791379e9581d 100644 (file)
@@ -131,26 +131,38 @@ private:
        std::shared_ptr<impl> impl_;
 };
 
+class frame_producer_registry;
+
 struct frame_producer_dependencies
 {
-       spl::shared_ptr<core::frame_factory>            frame_factory;
-       std::vector<spl::shared_ptr<video_channel>>     channels;
-       video_format_desc                                                       format_desc;
+       spl::shared_ptr<core::frame_factory>                    frame_factory;
+       std::vector<spl::shared_ptr<video_channel>>             channels;
+       video_format_desc                                                               format_desc;
+       spl::shared_ptr<const frame_producer_registry>  producer_registry;
 
        frame_producer_dependencies(
                        const spl::shared_ptr<core::frame_factory>& frame_factory,
                        const std::vector<spl::shared_ptr<video_channel>>& channels,
-                       const video_format_desc& format_desc);
+                       const video_format_desc& format_desc,
+                       const spl::shared_ptr<const frame_producer_registry> producer_registry);
 };
 
 typedef std::function<spl::shared_ptr<core::frame_producer>(const frame_producer_dependencies&, const std::vector<std::wstring>&)> producer_factory_t;
-void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.
-void register_thumbnail_producer_factory(const producer_factory_t& factory); // Not thread-safe.
 
-spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies&, const std::vector<std::wstring>& params);
-spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies&, const std::wstring& params);
+class frame_producer_registry : boost::noncopyable
+{
+public:
+       frame_producer_registry();
+       void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.
+       void register_thumbnail_producer_factory(const producer_factory_t& factory); // Not thread-safe.
+       spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies&, const std::vector<std::wstring>& params) const;
+       spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies&, const std::wstring& params) const;
+       spl::shared_ptr<core::frame_producer> create_thumbnail_producer(const frame_producer_dependencies&, const std::wstring& media_file) const;
+private:
+       struct impl;
+       spl::shared_ptr<impl> impl_;
+};
 
 spl::shared_ptr<core::frame_producer> create_destroy_proxy(spl::shared_ptr<core::frame_producer> producer);
-spl::shared_ptr<core::frame_producer> create_thumbnail_producer(const frame_producer_dependencies&, const std::wstring& media_file);
 
 }}
index 23c83729f348646dcf7497190d0f5cb76da8d3d7..f9aa4f39de9d54e30135db3af5f4b4d2b0408f79 100644 (file)
@@ -63,7 +63,7 @@ void deduce_expression(variable& var, const variable_repository& repo)
 
 void init(module_dependencies dependencies)
 {
-       register_producer_factory(create_xml_scene_producer);
+       dependencies.producer_registry->register_producer_factory(create_xml_scene_producer);
        dependencies.cg_registry->register_cg_producer(
                        L"scene",
                        { L".scene" },
@@ -127,7 +127,7 @@ spl::shared_ptr<core::frame_producer> create_xml_scene_producer(
        for (auto& elem : root.get_child(L"scene.layers"))
        {
                auto id = elem.second.get<std::wstring>(L"<xmlattr>.id");
-               auto producer = create_producer(dependencies, elem.second.get<std::wstring>(L"producer"));
+               auto producer = dependencies.producer_registry->create_producer(dependencies, elem.second.get<std::wstring>(L"producer"));
                auto& layer = scene->create_layer(producer, 0, 0, id);
                auto variable_prefix = L"layer." + id + L".";
 
index c8b79b35286b332a608f1bcb93b394b4be165773..ce9dcd16c2c41b26beb7a6ef966d365d9337463f 100644 (file)
 #include <core/frame/geometry.h>
 #include <core/frame/frame.h>
 #include <core/frame/draw_frame.h>
-
 #include <core/frame/frame_factory.h>
 #include <core/frame/pixel_format.h>
 #include <core/monitor/monitor.h>
-
 #include <core/consumer/frame_consumer.h>
+#include <core/module_dependencies.h>
+
 #include <modules/image/consumer/image_consumer.h>
 
 #include <common/except.h>
@@ -107,10 +107,10 @@ namespace caspar { namespace core {
                        return result;
                }
 
-               void init()
+               void init(module_dependencies dependencies)
                {
                        fonts = enumerate_fonts();
-                       register_producer_factory(&create_text_producer);
+                       dependencies.producer_registry->register_producer_factory(create_text_producer);
                }
 
                text_info& find_font_file(text_info& info)
index 197c94895091ffa338b6d8c3e746944aabd7238d..e9df2e7b04d94ee67bd0e2e787cf2995ecaf0c86 100644 (file)
@@ -37,7 +37,7 @@
 namespace caspar { namespace core {
        namespace text 
        {
-               void init();
+               void init(module_dependencies dependencies);
        }
 
 class text_producer : public frame_producer_base
index 8a27cba25a1ccd192fd47d3adebe3abef103fda4..3992778f70abcb11948d50fb3c4a94d314b47ebe 100644 (file)
@@ -98,19 +98,20 @@ struct thumbnail_output
 struct thumbnail_generator::impl
 {
 private:
-       boost::filesystem::path                                 media_path_;
-       boost::filesystem::path                                 thumbnails_path_;
-       int                                                                             width_;
-       int                                                                             height_;
-       spl::shared_ptr<image_mixer>                    image_mixer_;
-       spl::shared_ptr<diagnostics::graph>             graph_;
-       video_format_desc                                               format_desc_;
-       spl::unique_ptr<thumbnail_output>               output_;
-       mixer                                                                   mixer_;
-       thumbnail_creator                                               thumbnail_creator_;
-       spl::shared_ptr<media_info_repository>  media_info_repo_;
-       bool                                                                    mipmap_;
-       filesystem_monitor::ptr                                 monitor_;
+       boost::filesystem::path                                                 media_path_;
+       boost::filesystem::path                                                 thumbnails_path_;
+       int                                                                                             width_;
+       int                                                                                             height_;
+       spl::shared_ptr<image_mixer>                                    image_mixer_;
+       spl::shared_ptr<diagnostics::graph>                             graph_;
+       video_format_desc                                                               format_desc_;
+       spl::unique_ptr<thumbnail_output>                               output_;
+       mixer                                                                                   mixer_;
+       thumbnail_creator                                                               thumbnail_creator_;
+       spl::shared_ptr<media_info_repository>                  media_info_repo_;
+       spl::shared_ptr<const frame_producer_registry>  producer_registry_;
+       bool                                                                                    mipmap_;
+       filesystem_monitor::ptr                                                 monitor_;
 public:
        impl(
                        filesystem_monitor_factory& monitor_factory,
@@ -123,6 +124,7 @@ public:
                        int generate_delay_millis,
                        const thumbnail_creator& thumbnail_creator,
                        spl::shared_ptr<media_info_repository> media_info_repo,
+                       spl::shared_ptr<const frame_producer_registry> producer_registry,
                        bool mipmap)
                : media_path_(media_path)
                , thumbnails_path_(thumbnails_path)
@@ -134,6 +136,7 @@ public:
                , mixer_(graph_, image_mixer_)
                , thumbnail_creator_(thumbnail_creator)
                , media_info_repo_(std::move(media_info_repo))
+               , producer_registry_(std::move(producer_registry))
                , monitor_(monitor_factory.create(
                                media_path,
                                filesystem_event::ALL,
@@ -267,8 +270,8 @@ public:
 
                        try
                        {
-                               producer = create_thumbnail_producer(
-                                               frame_producer_dependencies(image_mixer_, { }, format_desc_),
+                               producer = producer_registry_->create_thumbnail_producer(
+                                               frame_producer_dependencies(image_mixer_, { }, format_desc_, producer_registry_),
                                                media_file);
                        }
                        catch (const boost::thread_interrupted&)
@@ -363,6 +366,7 @@ thumbnail_generator::thumbnail_generator(
                int generate_delay_millis,
                const thumbnail_creator& thumbnail_creator,
                spl::shared_ptr<media_info_repository> media_info_repo,
+               spl::shared_ptr<const frame_producer_registry> producer_registry,
                bool mipmap)
                : impl_(new impl(
                                monitor_factory,
@@ -374,6 +378,7 @@ thumbnail_generator::thumbnail_generator(
                                generate_delay_millis,
                                thumbnail_creator,
                                media_info_repo,
+                               producer_registry,
                                mipmap))
 {
 }
index 95c06cc167da5dff687215b5b783536250fac478..22634e219bb1d221156a7d897c753649f1c66dd0 100644 (file)
@@ -51,6 +51,7 @@ public:
                        int generate_delay_millis,
                        const thumbnail_creator& thumbnail_creator,
                        spl::shared_ptr<media_info_repository> media_info_repo,
+                       spl::shared_ptr<const frame_producer_registry> producer_registry,
                        bool mipmap);
        ~thumbnail_generator();
        void generate(const std::wstring& media_file);
index a7df304f964c664aa2e31872371b41160a45dcbe..71454d42cc8684f1c8c94bb7d4eb688363516f89 100644 (file)
@@ -84,7 +84,7 @@ void init(core::module_dependencies dependencies)
 {
        core::register_consumer_factory(create_consumer);
        core::register_preconfigured_consumer_factory(L"decklink", create_preconfigured_consumer);
-       core::register_producer_factory(create_producer);
+       dependencies.producer_registry->register_producer_factory(create_producer);
        dependencies.system_info_provider_repo->register_system_info_provider([](boost::property_tree::wptree& info)
        {
                info.add(L"system.decklink.version", version());
index f97705d825f7dab59ff130818fdf245449c08834..66ebb1c9c957f7a37edb0b4588a6eee0561307eb 100644 (file)
@@ -251,7 +251,7 @@ void init(core::module_dependencies dependencies)
        core::register_consumer_factory(create_streaming_consumer);
        core::register_preconfigured_consumer_factory(L"file", create_preconfigured_consumer);
        core::register_preconfigured_consumer_factory(L"stream", create_preconfigured_streaming_consumer);
-       core::register_producer_factory(create_producer);
+       dependencies.producer_registry->register_producer_factory(create_producer);
        
        dependencies.media_info_repo->register_extractor(
                        [](const std::wstring& file, const std::wstring& extension, core::media_info& info) -> bool
index b2c6c891d490e5679866c7da3703612f4c8fb765..ced2f370a2416268278557ea5190e1ac865b387d 100644 (file)
@@ -175,8 +175,8 @@ spl::shared_ptr<core::frame_producer> create_ct_producer(
 
 void init(core::module_dependencies dependencies)
 {
-       core::register_producer_factory(create_ct_producer);
-       core::register_producer_factory(create_swf_producer);
+       dependencies.producer_registry->register_producer_factory(create_ct_producer);
+       dependencies.producer_registry->register_producer_factory(create_swf_producer);
        dependencies.media_info_repo->register_extractor([](const std::wstring& file, const std::wstring& extension, core::media_info& info)
        {
                if (extension != L".CT" && extension != L".SWF")
index 9542044eaefc0cf58707cb4eff102d53ac227e37..bffdfb14221607dd1315a6d27e11593dc8388a33 100644 (file)
@@ -286,7 +286,7 @@ bool intercept_command_line(int argc, char** argv)
 
 void init(core::module_dependencies dependencies)
 {
-       core::register_producer_factory(html::create_producer);
+       dependencies.producer_registry->register_producer_factory(html::create_producer);
        
        CefMainArgs main_args;
        g_cef_executor.reset(new executor(L"cef"));
index 66c208205f5250346559bf142774ebcdefbe479d..f68dab212f3681b84c29c3c085bcb044c6f3a5cb 100644 (file)
@@ -47,9 +47,9 @@ std::wstring version()
 void init(core::module_dependencies dependencies)
 {
        FreeImage_Initialise();
-       core::register_producer_factory(create_scroll_producer);
-       core::register_producer_factory(create_producer);
-       core::register_thumbnail_producer_factory(create_thumbnail_producer);
+       dependencies.producer_registry->register_producer_factory(create_scroll_producer);
+       dependencies.producer_registry->register_producer_factory(create_producer);
+       dependencies.producer_registry->register_thumbnail_producer_factory(create_thumbnail_producer);
        core::register_consumer_factory(create_consumer);
        dependencies.media_info_repo->register_extractor([](const std::wstring& file, const std::wstring& extension, core::media_info& info)
        {
index 64079f002681312eaab794403c9b47c8395bd128..148e53c307518fbafd0f1ad1662a891842b77396 100644 (file)
@@ -455,7 +455,7 @@ spl::shared_ptr<core::frame_producer> create_psd_scene_producer(const core::fram
 
 void init(core::module_dependencies dependencies)
 {
-       core::register_producer_factory(create_psd_scene_producer);
+       dependencies.producer_registry->register_producer_factory(create_psd_scene_producer);
        dependencies.media_info_repo->register_extractor(
                        [](const std::wstring& file, const std::wstring& upper_case_extension, core::media_info& info)
                        {
index d229b819f2d0019287439f2abe9f5fa45951a194..89967769bbe42703375bdfb695da385fe880651b 100644 (file)
@@ -30,7 +30,7 @@ namespace caspar { namespace reroute {
 
 void init(core::module_dependencies dependencies)
 {
-       core::register_producer_factory(reroute::create_producer);
+       dependencies.producer_registry->register_producer_factory(reroute::create_producer);
 }
 
 }}
index bc5373c803321ec38371b6650c83feea3eb3a052..7cb9553cfa7aa58fc3ceb3d35d66c79962acdb87 100644 (file)
@@ -43,6 +43,7 @@ namespace amcp {
                spl::shared_ptr<core::cg_producer_registry>                             cg_registry;
                spl::shared_ptr<core::system_info_provider_repository>  system_info_repo;
                std::shared_ptr<core::thumbnail_generator>                              thumb_gen;
+               spl::shared_ptr<const core::frame_producer_registry>    producer_registry;
                std::promise<bool>&                                                                             shutdown_server_now;
                std::vector<std::wstring>                                                               parameters;
 
@@ -59,6 +60,7 @@ namespace amcp {
                                spl::shared_ptr<core::cg_producer_registry> cg_registry,
                                spl::shared_ptr<core::system_info_provider_repository> system_info_repo,
                                std::shared_ptr<core::thumbnail_generator> thumb_gen,
+                               spl::shared_ptr<const core::frame_producer_registry> producer_registry,
                                std::promise<bool>& shutdown_server_now)
                        : client(std::move(client))
                        , channel(channel)
@@ -70,6 +72,7 @@ namespace amcp {
                        , cg_registry(std::move(cg_registry))
                        , system_info_repo(std::move(system_info_repo))
                        , thumb_gen(std::move(thumb_gen))
+                       , producer_registry(std::move(producer_registry))
                        , shutdown_server_now(shutdown_server_now)
                {
                }
index 8a07dfd3d26802673a49811bc375295f23c576c8..5a187c9d7fb0d19f3b31e2863383380515e9e200 100644 (file)
@@ -41,6 +41,7 @@
 #include <core/producer/frame_producer.h>
 #include <core/help/help_repository.h>
 #include <core/help/help_sink.h>
+#include <core/help/util.h>
 #include <core/video_format.h>
 #include <core/producer/transition/transition_producer.h>
 #include <core/frame/frame_transform.h>
@@ -278,7 +279,8 @@ core::frame_producer_dependencies get_producer_dependencies(const std::shared_pt
                        cpplinq::from(ctx.channels)
                                        .select([](channel_context c) { return spl::make_shared_ptr(c.channel); })
                                        .to_vector(),
-                       channel->video_format_desc());
+                       channel->video_format_desc(),
+                       ctx.producer_registry);
 }
 
 // Basic Commands
@@ -368,7 +370,7 @@ std::wstring loadbg_command(command_context& ctx)
        core::diagnostics::call_context::for_thread().layer = ctx.layer_index();
 
        auto channel = ctx.channel.channel;
-       auto pFP = create_producer(get_producer_dependencies(channel, ctx), ctx.parameters);
+       auto pFP = ctx.producer_registry->create_producer(get_producer_dependencies(channel, ctx), ctx.parameters);
 
        if (pFP == frame_producer::empty())
                CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(ctx.parameters.size() > 0 ? ctx.parameters[0] : L""));
@@ -402,7 +404,7 @@ std::wstring load_command(command_context& ctx)
        core::diagnostics::scoped_call_context save;
        core::diagnostics::call_context::for_thread().video_channel = ctx.channel_index + 1;
        core::diagnostics::call_context::for_thread().layer = ctx.layer_index();
-       auto pFP = create_producer(get_producer_dependencies(ctx.channel.channel, ctx), ctx.parameters);
+       auto pFP = ctx.producer_registry->create_producer(get_producer_dependencies(ctx.channel.channel, ctx), ctx.parameters);
        ctx.channel.channel->stage().load(ctx.layer_index(), pFP, true);
 
        return L"202 LOAD OK\r\n";
@@ -1801,7 +1803,7 @@ void mixer_mipmap_describer(core::help_sink& sink, const core::help_repository&
                ->text(L"If no argument is given the current state is returned.");
        sink.para()->text(L"Mipmapping reduces aliasing when downscaling/perspective transforming.");
        sink.para()->text(L"Examples:");
-       sink.example(L">> MIXER 1-10 MIPMAP 1", L"for turing mipmapping on");
+       sink.example(L">> MIXER 1-10 MIPMAP 1", L"for turning mipmapping on");
        sink.example(
                L">> MIXER 1-10 MIPMAP\n"
                L"<< 201 MIXER OK\n"
@@ -1989,7 +1991,7 @@ std::wstring channel_grid_command(command_context& ctx)
                if (channel.channel != self.channel)
                {
                        core::diagnostics::call_context::for_thread().layer = index;
-                       auto producer = create_producer(get_producer_dependencies(channel.channel, ctx), L"route://" + boost::lexical_cast<std::wstring>(channel.channel->index()));
+                       auto producer = ctx.producer_registry->create_producer(get_producer_dependencies(channel.channel, ctx), L"route://" + boost::lexical_cast<std::wstring>(channel.channel->index()));
                        self.channel->stage().load(index, producer, false);
                        self.channel->stage().play(index);
                        index++;
@@ -2411,6 +2413,7 @@ void help_describer(core::help_sink& sink, const core::help_repository& reposito
 
 std::wstring help_command(command_context& ctx)
 {
+       static const int WIDTH = 80;
        struct max_width_sink : public core::help_sink
        {
                std::size_t max_width = 0;
@@ -2441,12 +2444,13 @@ std::wstring help_command(command_context& ctx)
 
        struct simple_paragraph_builder : core::paragraph_builder
        {
-               std::wstringstream& out;
+               std::wostringstream out;
+               std::wstringstream& commit_to;
 
-               simple_paragraph_builder(std::wstringstream& out) : out(out) { }
+               simple_paragraph_builder(std::wstringstream& out) : commit_to(out) { }
                ~simple_paragraph_builder()
                {
-                       out << L"\n\n";
+                       commit_to << core::wordwrap(out.str(), WIDTH) << L"\n";
                }
                spl::shared_ptr<paragraph_builder> text(std::wstring text) override
                {
@@ -2463,10 +2467,15 @@ std::wstring help_command(command_context& ctx)
                std::wstringstream& out;
 
                simple_definition_list_builder(std::wstringstream& out) : out(out) { }
+               ~simple_definition_list_builder()
+               {
+                       out << L"\n";
+               }
+
                spl::shared_ptr<definition_list_builder> item(std::wstring term, std::wstring description) override
                {
-                       out << L"  " << std::move(term) << L"\n";
-                       out << L"    " << std::move(description) << L"\n\n";
+                       out << core::indent(core::wordwrap(term, WIDTH - 2), L"  ");
+                       out << core::indent(core::wordwrap(description, WIDTH - 4), L"    ");
                        return shared_from_this();
                }
        };
@@ -2479,8 +2488,8 @@ std::wstring help_command(command_context& ctx)
 
                void syntax(const std::wstring& syntax) override
                {
-                       out << L"Syntax\n";
-                       out << L"  " << syntax << L"\n\n";
+                       out << L"Syntax:\n";
+                       out << core::indent(core::wordwrap(syntax, WIDTH - 2), L"  ") << L"\n";
                };
 
                spl::shared_ptr<core::paragraph_builder> para() override
@@ -2495,9 +2504,11 @@ std::wstring help_command(command_context& ctx)
 
                void example(const std::wstring& code, const std::wstring& caption = L"") override
                {
-                       out << L"  " << code << L"\n";
+                       out << core::indent(core::wordwrap(code, WIDTH - 2), L"  ");
+
                        if (!caption.empty())
-                               out << L"  ..." << caption << L"\n";
+                               out << core::indent(core::wordwrap(L"..." + caption, WIDTH - 2), L"  ");
+
                        out << L"\n";
                }
        private:
index d993c738ea2b94fe7d823b60bb61d841630cd610..e1612eb14769fdf486547923fc2bb719e16d37c1 100644 (file)
@@ -69,6 +69,7 @@ struct amcp_command_repository::impl
        spl::shared_ptr<core::system_info_provider_repository>          system_info_provider_repo;
        spl::shared_ptr<core::cg_producer_registry>                                     cg_registry;
        spl::shared_ptr<core::help_repository>                                          help_repo;
+       spl::shared_ptr<const core::frame_producer_registry>            producer_registry;
        std::promise<bool>&                                                                                     shutdown_server_now;
 
        std::map<std::wstring, std::pair<amcp_command_func, int>>       commands;
@@ -81,12 +82,14 @@ struct amcp_command_repository::impl
                        const spl::shared_ptr<core::system_info_provider_repository>& system_info_provider_repo,
                        const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
                        const spl::shared_ptr<core::help_repository>& help_repo,
+                       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry,
                        std::promise<bool>& shutdown_server_now)
                : thumb_gen(thumb_gen)
                , media_info_repo(media_info_repo)
                , system_info_provider_repo(system_info_provider_repo)
                , cg_registry(cg_registry)
                , help_repo(help_repo)
+               , producer_registry(producer_registry)
                , shutdown_server_now(shutdown_server_now)
        {
                int index = 0;
@@ -106,17 +109,18 @@ amcp_command_repository::amcp_command_repository(
                const spl::shared_ptr<core::system_info_provider_repository>& system_info_provider_repo,
                const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
                const spl::shared_ptr<core::help_repository>& help_repo,
+               const spl::shared_ptr<const core::frame_producer_registry>& producer_registry,
                std::promise<bool>& shutdown_server_now)
-       : impl_(new impl(channels, thumb_gen, media_info_repo, system_info_provider_repo, cg_registry, help_repo, shutdown_server_now))
+       : impl_(new impl(channels, thumb_gen, media_info_repo, system_info_provider_repo, cg_registry, help_repo, producer_registry, shutdown_server_now))
 {
 }
 
-AMCPCommand::ptr_type amcp_command_repository::create_command(const std::wstring& s, IO::ClientInfoPtr client, std::list<std::wstring>& tokens)
+AMCPCommand::ptr_type amcp_command_repository::create_command(const std::wstring& s, IO::ClientInfoPtr client, std::list<std::wstring>& tokens) const
 {
        auto& self = *impl_;
 
        command_context ctx(
-                       client,
+                       std::move(client),
                        channel_context(),
                        -1,
                        -1,
@@ -126,6 +130,7 @@ AMCPCommand::ptr_type amcp_command_repository::create_command(const std::wstring
                        self.cg_registry,
                        self.system_info_provider_repo,
                        self.thumb_gen,
+                       self.producer_registry,
                        self.shutdown_server_now);
 
        auto command = find_command(self.commands, s, ctx, tokens);
@@ -146,7 +151,7 @@ AMCPCommand::ptr_type amcp_command_repository::create_channel_command(
                IO::ClientInfoPtr client,
                unsigned int channel_index,
                int layer_index,
-               std::list<std::wstring>& tokens)
+               std::list<std::wstring>& tokens) const
 {
        auto& self = *impl_;
 
@@ -163,6 +168,7 @@ AMCPCommand::ptr_type amcp_command_repository::create_channel_command(
                        self.cg_registry,
                        self.system_info_provider_repo,
                        self.thumb_gen,
+                       self.producer_registry,
                        self.shutdown_server_now);
 
        auto command = find_command(self.channel_commands, s, ctx, tokens);
index daa2f7b3c5496b0b7bc3a1e9b603f169dce8d890..0c208b2cfcdb194a67da51d8abb3a76da2b27917 100644 (file)
@@ -43,15 +43,16 @@ public:
                        const spl::shared_ptr<core::system_info_provider_repository>& system_info_provider_repo,
                        const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
                        const spl::shared_ptr<core::help_repository>& help_repo,
+                       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry,
                        std::promise<bool>& shutdown_server_now);
 
-       AMCPCommand::ptr_type create_command(const std::wstring& s, IO::ClientInfoPtr client, std::list<std::wstring>& tokens);
+       AMCPCommand::ptr_type create_command(const std::wstring& s, IO::ClientInfoPtr client, std::list<std::wstring>& tokens) const;
        AMCPCommand::ptr_type create_channel_command(
                        const std::wstring& s,
                        IO::ClientInfoPtr client,
                        unsigned int channel_index,
                        int layer_index,
-                       std::list<std::wstring>& tokens);
+                       std::list<std::wstring>& tokens) const;
 
        const std::vector<channel_context>& channels() const;
 
index 84a36961b7eed15691723c76d16afcc3600ede6d..d779d2a44a89c5113f1bf368c322c72c1842776a 100644 (file)
@@ -47,11 +47,13 @@ const wchar_t CIIProtocolStrategy::TokenDelimiter = L'\\';
 
 CIIProtocolStrategy::CIIProtocolStrategy(
                const std::vector<spl::shared_ptr<core::video_channel>>& channels, 
-               const spl::shared_ptr<core::cg_producer_registry>& cg_registry)
+               const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
+               const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)
        : executor_(L"CIIProtocolStrategy")
        , pChannel_(channels.at(0))
        , channels_(channels)
        , cg_registry_(cg_registry)
+       , producer_registry_(producer_registry)
 {
 }
 
@@ -202,7 +204,7 @@ void CIIProtocolStrategy::DisplayMediaFile(const std::wstring& filename)
        core::diagnostics::call_context::for_thread().video_channel = 1;
        core::diagnostics::call_context::for_thread().layer = 0;
 
-       auto pFP = create_producer(get_dependencies(), filename);
+       auto pFP = get_producer_registry()->create_producer(get_dependencies(), filename);
        auto pTransition = create_transition_producer(GetChannel()->video_format_desc().field_mode, pFP, transition);
 
        try
index 59fe90da94a822bc85559bf7963448a2c576ae0c..46e2fc9e1f1f765c82a71973610c86f98cf25953 100644 (file)
@@ -40,7 +40,10 @@ namespace caspar { namespace protocol { namespace cii {
 class CIIProtocolStrategy : public IO::IProtocolStrategy
 {
 public:
-       CIIProtocolStrategy(const std::vector<spl::shared_ptr<core::video_channel>>& channels, const spl::shared_ptr<core::cg_producer_registry>& cg_registry);
+       CIIProtocolStrategy(
+                       const std::vector<spl::shared_ptr<core::video_channel>>& channels,
+                       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
+                       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry);
 
        void Parse(const std::wstring& message, IO::ClientInfoPtr pClientInfo);
        std::string GetCodepage() const { return "ISO-8859-1"; }        //ISO 8859-1
@@ -49,7 +52,8 @@ public:
 
        spl::shared_ptr<core::video_channel> GetChannel() const { return pChannel_; }
        spl::shared_ptr<core::cg_producer_registry> get_cg_registry() const { return cg_registry_; }
-       core::frame_producer_dependencies get_dependencies() const { return core::frame_producer_dependencies(GetChannel()->frame_factory(), channels_, GetChannel()->video_format_desc()); }
+       spl::shared_ptr<const core::frame_producer_registry> get_producer_registry() const { return producer_registry_; }
+       core::frame_producer_dependencies get_dependencies() const { return core::frame_producer_dependencies(GetChannel()->frame_factory(), channels_, GetChannel()->video_format_desc(), producer_registry_); }
 
        void DisplayMediaFile(const std::wstring& filename);
        void DisplayTemplate(const std::wstring& titleName);
@@ -97,6 +101,7 @@ private:
        std::wstring currentProfile_;
        spl::shared_ptr<core::video_channel> pChannel_;
        spl::shared_ptr<core::cg_producer_registry> cg_registry_;
+       spl::shared_ptr<const core::frame_producer_registry> producer_registry_;
        std::vector<spl::shared_ptr<core::video_channel>> channels_;
 };
 
index 409ccd11bb194b910b99d73dc5e4104c219fc157..6523bedc3846080655116168403af84f1b4caa9d 100644 (file)
@@ -143,9 +143,10 @@ private:
 
 clk_protocol_strategy_factory::clk_protocol_strategy_factory(
                const std::vector<spl::shared_ptr<core::video_channel>>& channels,
-               const spl::shared_ptr<core::cg_producer_registry>& cg_registry)
+               const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
+               const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)
 {
-       add_command_handlers(command_processor_, channels, channels.at(0), cg_registry);
+       add_command_handlers(command_processor_, channels, channels.at(0), cg_registry, producer_registry);
 }
 
 IO::protocol_strategy<wchar_t>::ptr clk_protocol_strategy_factory::create(
index fc30364bc26118e8a486a2247214c87342b45796..044cff4086f820d44a701031591855fc82df77ba 100644 (file)
@@ -35,7 +35,8 @@ class clk_protocol_strategy_factory : public IO::protocol_strategy_factory<wchar
 public:
        clk_protocol_strategy_factory(
                        const std::vector<spl::shared_ptr<core::video_channel>>& channels,
-                       const spl::shared_ptr<core::cg_producer_registry>& cg_registry);
+                       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
+                       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry);
 
        virtual IO::protocol_strategy<wchar_t>::ptr create(
                const IO::client_connection<wchar_t>::ptr& client_connection);
index 130a50d3016b9e8e4177e3a0f7979f0e5ab5dd2a..8c10362134250186109764a237681a2ad36e0656 100644 (file)
@@ -40,18 +40,21 @@ namespace caspar { namespace protocol { namespace CLK {
 \r
 class command_context\r
 {\r
-       bool                                                                                            clock_loaded_ = false;\r
-       std::vector<spl::shared_ptr<core::video_channel>>       channels_;\r
-       spl::shared_ptr<core::video_channel>                            channel_;\r
-       spl::shared_ptr<core::cg_producer_registry>                     cg_registry_;\r
+       bool                                                                                                    clock_loaded_ = false;\r
+       std::vector<spl::shared_ptr<core::video_channel>>               channels_;\r
+       spl::shared_ptr<core::video_channel>                                    channel_;\r
+       spl::shared_ptr<core::cg_producer_registry>                             cg_registry_;\r
+       spl::shared_ptr<const core::frame_producer_registry>    producer_registry_;\r
 public:\r
        command_context(\r
                        const std::vector<spl::shared_ptr<core::video_channel>>& channels,\r
                        const spl::shared_ptr<core::video_channel>& channel,\r
-                       const spl::shared_ptr<core::cg_producer_registry>& cg_registry)\r
+                       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,\r
+                       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)\r
                : channels_(channels)\r
                , channel_(channel)\r
                , cg_registry_(cg_registry)\r
+               , producer_registry_(producer_registry)\r
        {\r
        }\r
 \r
@@ -59,9 +62,9 @@ public:
        {\r
                if (!clock_loaded_) \r
                {\r
-                       core::frame_producer_dependencies dependencies(channel_->frame_factory(), channels_, channel_->video_format_desc());\r
+                       core::frame_producer_dependencies dependencies(channel_->frame_factory(), channels_, channel_->video_format_desc(), producer_registry_);\r
                        cg_registry_->get_or_create_proxy(channel_, dependencies, core::cg_proxy::DEFAULT_LAYER, L"hawrysklocka/clock")->add(\r
-                               0, L"hawrysklocka/clock", true, L"", data);\r
+                                       0, L"hawrysklocka/clock", true, L"", data);\r
                        clock_loaded_ = true;\r
                }\r
                else\r
@@ -160,9 +163,10 @@ void add_command_handlers(
        clk_command_processor& processor,\r
        const std::vector<spl::shared_ptr<core::video_channel>>& channels,\r
        const spl::shared_ptr<core::video_channel>& channel,\r
-       const spl::shared_ptr<core::cg_producer_registry>& cg_registry)\r
+       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,\r
+       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)\r
 {\r
-       auto context = spl::make_shared<command_context>(channels, channel, cg_registry);\r
+       auto context = spl::make_shared<command_context>(channels, channel, cg_registry, producer_registry);\r
 \r
        processor\r
                .add_handler(L"DUR", \r
index a4c20b204160dfa0a2ecbb231ae6c7a30fccaa8f..31d89086a26fd2327123354caebdd5bb7264d725 100644 (file)
@@ -38,6 +38,7 @@ void add_command_handlers(
        clk_command_processor& processor,\r
        const std::vector<spl::shared_ptr<core::video_channel>>& channels,\r
        const spl::shared_ptr<core::video_channel>& channel,\r
-       const spl::shared_ptr<core::cg_producer_registry>& cg_registry);\r
+       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,\r
+       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry);\r
 \r
 }}}\r
index 4e31749b32b07c60b89f7251016e481a429cf9fa..3a086c017f99fe9d6e88b83ca5031f499e361122 100644 (file)
@@ -35,6 +35,16 @@ set(HEADERS
 add_executable(casparcg ${SOURCES} ${HEADERS} ${OS_SPECIFIC_SOURCES})
 add_precompiled_header(casparcg stdafx.h FORCEINCLUDE)
 
+add_executable(generate_docs generate_docs.cpp included_modules.h)
+target_link_libraries(generate_docs
+               protocol
+
+               "${CASPARCG_MODULE_PROJECTS}"
+
+               reroute
+)
+
+
 include_directories(..)
 include_directories(${BOOST_INCLUDE_PATH})
 include_directories(${RXCPP_INCLUDE_PATH})
diff --git a/shell/generate_docs.cpp b/shell/generate_docs.cpp
new file mode 100644 (file)
index 0000000..57542cf
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Helge Norberg, helge.norberg@svt.se
+*/
+
+#include "included_modules.h"
+
+#include <common/env.h>
+#include <common/log.h>
+
+#include <core/producer/media_info/in_memory_media_info_repository.h>
+#include <core/help/help_repository.h>
+#include <core/help/help_sink.h>
+#include <core/help/util.h>
+
+#include <protocol/amcp/amcp_command_repository.h>
+#include <protocol/amcp/AMCPCommandsImpl.h>
+
+#include <boost/filesystem/fstream.hpp>
+
+#include <iostream>
+#include <sstream>
+
+using namespace caspar;
+
+static const int WIDTH = 150;
+
+class mediawiki_paragraph_builder : public core::paragraph_builder
+{
+       std::wostringstream     out_;
+       std::wostream&          commit_to_;
+public:
+       mediawiki_paragraph_builder(std::wostream& out)
+               : commit_to_(out)
+       {
+       }
+
+       ~mediawiki_paragraph_builder()
+       {
+               commit_to_ << core::wordwrap(out_.str(), WIDTH) << std::endl;
+       }
+
+       spl::shared_ptr<paragraph_builder> text(std::wstring text) override
+       {
+               out_ << std::move(text);
+               return shared_from_this();
+       };
+
+       spl::shared_ptr<paragraph_builder> code(std::wstring text) override
+       {
+               out_ << L"<code>" << std::move(text) << L"</code>";
+               return shared_from_this();
+       };
+
+       spl::shared_ptr<paragraph_builder> see(std::wstring item) override
+       {
+               out_ << L"[[#" << item << L"|" << item << L"]]";
+               return shared_from_this();
+       };
+
+       spl::shared_ptr<paragraph_builder> url(std::wstring url, std::wstring name) override
+       {
+               out_ << L"[" << std::move(url) << L" " << std::move(name) << L"]";
+               return shared_from_this();
+       };
+};
+
+class mediawiki_definition_list_builder : public core::definition_list_builder
+{
+       std::wostream& out_;
+public:
+       mediawiki_definition_list_builder(std::wostream& out)
+               : out_(out)
+       {
+       }
+
+       ~mediawiki_definition_list_builder()
+       {
+               out_ << L"\n" << std::endl;
+       }
+
+       spl::shared_ptr<definition_list_builder> item(std::wstring term, std::wstring description) override
+       {
+               out_ << L"; <code>" << term << L"</code>\n";
+               out_ << L": " << description << L"\n";
+
+               return shared_from_this();
+       };
+};
+
+class mediawiki_help_sink : public core::help_sink
+{
+       std::wostream& out_;
+public:
+       mediawiki_help_sink(std::wostream& out)
+               : out_(out)
+       {
+       }
+
+       void start_section(std::wstring title)
+       {
+               out_ << L"=" << title << L"=\n" << std::endl;
+       }
+
+       void syntax(const std::wstring& syntax) override
+       {
+               out_ << L"Syntax:\n";
+               out_ << core::indent(core::wordwrap(syntax, WIDTH - 1), L" ") << std::endl;
+       }
+
+       spl::shared_ptr<core::paragraph_builder> para() override
+       {
+               return spl::make_shared<mediawiki_paragraph_builder>(out_);
+       }
+
+       spl::shared_ptr<core::definition_list_builder> definitions() override
+       {
+               return spl::make_shared<mediawiki_definition_list_builder>(out_);
+       }
+
+       void example(const std::wstring& code, const std::wstring& caption) override
+       {
+               out_ << core::indent(core::wordwrap(code, WIDTH - 1), L" ");
+
+               if (!caption.empty())
+                       out_ << core::wordwrap(L"..." + caption, WIDTH - 1);
+
+               out_ << std::endl;
+       }
+private:
+       void begin_item(const std::wstring& name) override 
+       {
+               out_ << L"==" << name << L"==\n" << std::endl;
+       }
+};
+
+void generate_amcp_commands_help(const core::help_repository& help_repo)
+{
+       boost::filesystem::wofstream file(L"amcp_commands_help.wiki");
+       mediawiki_help_sink sink(file);
+
+       auto print_section = [&](std::wstring title)
+       {
+               sink.start_section(title);
+               help_repo.help({ L"AMCP", title }, sink);
+       };
+
+       print_section(L"Basic Commands");
+       print_section(L"Data Commands");
+       print_section(L"Template Commands");
+       print_section(L"Mixer Commands");
+       print_section(L"Thumbnail Commands");
+       print_section(L"Query Commands");
+       file.flush();
+}
+
+int main(int argc, char** argv)
+{
+       //env::configure(L"casparcg.config");
+       //log::set_log_level(L"info");
+
+       spl::shared_ptr<core::system_info_provider_repository> system_info_provider_repo;
+       spl::shared_ptr<core::cg_producer_registry> cg_registry;
+       auto media_info_repo = core::create_in_memory_media_info_repository();
+       spl::shared_ptr<core::help_repository> help_repo;
+       spl::shared_ptr<core::frame_producer_registry> producer_registry;
+       std::promise<bool> shutdown_server_now;
+       protocol::amcp::amcp_command_repository repo(
+                       { },
+                       nullptr,
+                       media_info_repo,
+                       system_info_provider_repo,
+                       cg_registry,
+                       help_repo,
+                       producer_registry,
+                       shutdown_server_now);
+
+       protocol::amcp::register_commands(repo);
+
+       core::module_dependencies dependencies(system_info_provider_repo, cg_registry, media_info_repo, producer_registry);
+       initialize_modules(dependencies);
+
+       generate_amcp_commands_help(*help_repo);
+
+       uninitialize_modules();
+       
+       return 0;
+}
index 79bd335483d1e4eb27650874e76ebf08b8c317ef..6dd2a4c677dfe52a0af9e4cc6258ef950ecff53c 100644 (file)
@@ -95,6 +95,7 @@ struct server::impl : boost::noncopyable
        boost::thread                                                                           initial_media_info_thread_;
        spl::shared_ptr<system_info_provider_repository>        system_info_provider_repo_;
        spl::shared_ptr<core::cg_producer_registry>                     cg_registry_;
+       spl::shared_ptr<core::frame_producer_registry>          producer_registry_;
        tbb::atomic<bool>                                                                       running_;
        std::shared_ptr<thumbnail_generator>                            thumbnail_generator_;
        std::promise<bool>&                                                                     shutdown_server_now_;
@@ -110,12 +111,13 @@ struct server::impl : boost::noncopyable
                diag_subject_->attach_parent(monitor_subject_);
 
                module_dependencies dependencies(
-                       system_info_provider_repo_,
-                       cg_registry_,
-                       media_info_repo_);
+                               system_info_provider_repo_,
+                               cg_registry_,
+                               media_info_repo_,
+                               producer_registry_);
 
                initialize_modules(dependencies);
-               core::text::init();
+               core::text::init(dependencies);
                core::scene::init(dependencies);
        }
 
@@ -260,6 +262,7 @@ struct server::impl : boost::noncopyable
                        pt.get(L"configuration.thumbnails.generate-delay-millis", 2000),
                        &image::write_cropped_png,
                        media_info_repo_,
+                       producer_registry_,
                        pt.get(L"configuration.thumbnails.mipmap", true)));
 
                CASPAR_LOG(info) << L"Initialized thumbnail generator.";
@@ -274,6 +277,7 @@ struct server::impl : boost::noncopyable
                                system_info_provider_repo_,
                                cg_registry_,
                                help_repo_,
+                               producer_registry_,
                                shutdown_server_now_);
                amcp::register_commands(*amcp_command_repo_);
 
@@ -311,11 +315,11 @@ struct server::impl : boost::noncopyable
                if(boost::iequals(name, L"AMCP"))
                        return wrap_legacy_protocol("\r\n", spl::make_shared<amcp::AMCPProtocolStrategy>(spl::make_shared_ptr(amcp_command_repo_)));
                else if(boost::iequals(name, L"CII"))
-                       return wrap_legacy_protocol("\r\n", spl::make_shared<cii::CIIProtocolStrategy>(channels_, cg_registry_));
+                       return wrap_legacy_protocol("\r\n", spl::make_shared<cii::CIIProtocolStrategy>(channels_, cg_registry_, producer_registry_));
                else if(boost::iequals(name, L"CLOCK"))
                        return spl::make_shared<to_unicode_adapter_factory>(
                                        "ISO-8859-1",
-                                       spl::make_shared<CLK::clk_protocol_strategy_factory>(channels_, cg_registry_));
+                                       spl::make_shared<CLK::clk_protocol_strategy_factory>(channels_, cg_registry_, producer_registry_));
                
                CASPAR_THROW_EXCEPTION(caspar_exception() << arg_name_info(L"name") << arg_value_info(name) << msg_info(L"Invalid protocol"));
        }