]> git.sesse.net Git - casparcg/commitdiff
Reduced the coupling between specific modules and InfoCommand, VersionCommand and...
authorHelge Norberg <helge.norberg@svt.se>
Tue, 7 Apr 2015 15:43:56 +0000 (17:43 +0200)
committerHelge Norberg <helge.norberg@svt.se>
Tue, 7 Apr 2015 15:43:56 +0000 (17:43 +0200)
21 files changed:
core/CMakeLists.txt
core/frame.h [deleted file]
core/system_info_provider.cpp [new file with mode: 0644]
core/system_info_provider.h [new file with mode: 0644]
modules/bluefish/bluefish.cpp
modules/bluefish/bluefish.h
modules/decklink/decklink.cpp
modules/decklink/decklink.h
modules/ffmpeg/ffmpeg.cpp
modules/ffmpeg/ffmpeg.h
modules/flash/flash.cpp
modules/flash/flash.h
modules/image/image.cpp
modules/image/image.h
protocol/amcp/AMCPCommandsImpl.cpp
protocol/amcp/AMCPCommandsImpl.h
protocol/amcp/AMCPProtocolStrategy.cpp
protocol/amcp/AMCPProtocolStrategy.h
shell/main.cpp
shell/server.cpp
shell/server.h

index cd11417454ee636554c750522f75c78230759cd3..a4d3c35866b833a3df8a92642b4eea498c2bbfed 100644 (file)
@@ -45,6 +45,7 @@ set(SOURCES
                producer/layer.cpp
                producer/stage.cpp
 
+               system_info_provider.cpp
                StdAfx.cpp
                thumbnail_generator.cpp
                video_channel.cpp
@@ -106,7 +107,7 @@ set(HEADERS
                producer/stage.h
                producer/variable.h
 
-               frame.h
+               system_info_provider.h
                StdAfx.h
                thumbnail_generator.h
                video_channel.h
diff --git a/core/frame.h b/core/frame.h
deleted file mode 100644 (file)
index 45d6bfd..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#pragma once
-
-#include <boost/noncopyable.hpp>
-#include <boost/range.hpp>
-
-#include <stdint.h>
-
-#include "frame/pixel_format.h"
-#include "video_format.h"
-
-namespace caspar { namespace core {
-
-struct data_frame : boost::noncopyable
-{
-       virtual ~frame()
-       {
-       }
-
-       virtual const struct  pixel_format_desc& get_pixel_format_desc() const = 0;
-
-       virtual const boost::iterator_range<const uint8_t*> image_data() const = 0;
-       virtual const boost::iterator_range<const int32_t*> audio_data() const = 0;
-       
-       virtual const boost::iterator_range<uint8_t*> image_data() = 0;
-       virtual const boost::iterator_range<int32_t*> audio_data() = 0;
-
-       virtual double get_frame_rate() const = 0;
-       virtual field_mode get_field_mode() const = 0;
-
-       virtual int width() const = 0;
-       virtual int height() const = 0;
-
-       static safe_ptr<frame> empty()
-       {
-               struct empty_frame : public frame
-               {
-                       virtual const struct  video_format_desc& get_video_format_desc() const
-                       {
-                               static video_format_desc invalid;
-                               return invalid;
-                       }
-                       virtual const struct  pixel_format_desc& get_pixel_format_desc() const 
-                       {
-                               static pixel_format_desc invalid;
-                               return invalid;
-                       }
-                       virtual const boost::iterator_range<const uint8_t*> image_data() const 
-                       {
-                               return boost::iterator_range<const uint8_t*>();
-                       }
-                       virtual const boost::iterator_range<const int32_t*> audio_data() const 
-                       {
-                               return boost::iterator_range<const int32_t*>();
-                       }
-                       const boost::iterator_range<uint8_t*> image_data()
-                       {
-                               return boost::iterator_range<uint8_t*>();
-                       }
-                       const boost::iterator_range<int32_t*> audio_data()
-                       {
-                               return boost::iterator_range<int32_t*>();
-                       }
-                       virtual double get_frame_rate() const
-                       {
-                               return 0.0;
-                       }
-                       virtual field_mode get_field_mode() const
-                       {
-                               return field_mode::empty;
-                       }
-                       virtual int width() const
-                       {
-                               return 0;
-                       }
-                       virtual int height() const
-                       {
-                               return 0;
-                       }
-               };
-
-               static safe_ptr<empty_frame> empty;
-               return empty;
-       }
-};
-
-}}
\ No newline at end of file
diff --git a/core/system_info_provider.cpp b/core/system_info_provider.cpp
new file mode 100644 (file)
index 0000000..c26758a
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+* 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 "StdAfx.h"
+
+#include "system_info_provider.h"
+
+#include <boost/property_tree/ptree.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/lock_guard.hpp>
+#include <boost/algorithm/string/case_conv.hpp>
+
+#include <vector>
+#include <map>
+
+namespace caspar { namespace core {
+
+struct system_info_provider_repository::impl
+{
+       mutable boost::mutex                                            mutex_;
+       std::vector<system_info_provider>                       info_providers_;
+       std::map<std::wstring, version_provider>        version_providers_;
+
+       void register_system_info_provider(system_info_provider provider)
+       {
+               boost::lock_guard<boost::mutex> lock(mutex_);
+
+               info_providers_.push_back(std::move(provider));
+       }
+
+       void register_version_provider(const std::wstring& version_name, version_provider provider)
+       {
+               boost::lock_guard<boost::mutex> lock(mutex_);
+
+               version_providers_.insert(std::make_pair(boost::algorithm::to_lower_copy(version_name), std::move(provider)));
+       }
+
+       void fill_information(boost::property_tree::wptree& info) const
+       {
+               boost::lock_guard<boost::mutex> lock(mutex_);
+
+               for (auto& provider : info_providers_)
+                       provider(info);
+       }
+
+       std::wstring get_version(const std::wstring& version_name) const
+       {
+               boost::lock_guard<boost::mutex> lock(mutex_);
+               
+               auto found = version_providers_.find(boost::algorithm::to_lower_copy(version_name));
+
+               if (found == version_providers_.end())
+                       return L"";
+
+               return found->second();
+       }
+};
+
+system_info_provider_repository::system_info_provider_repository()
+       : impl_(new impl)
+{
+}
+
+void system_info_provider_repository::register_system_info_provider(system_info_provider provider)
+{
+       impl_->register_system_info_provider(std::move(provider));
+}
+
+void system_info_provider_repository::register_version_provider(
+               const std::wstring& version_name, version_provider provider)
+{
+       impl_->register_version_provider(version_name, provider);
+}
+
+void system_info_provider_repository::fill_information(boost::property_tree::wptree& info) const
+{
+       impl_->fill_information(info);
+}
+
+std::wstring system_info_provider_repository::get_version(const std::wstring& version_name) const
+{
+       return impl_->get_version(version_name);
+}
+
+}}
diff --git a/core/system_info_provider.h b/core/system_info_provider.h
new file mode 100644 (file)
index 0000000..0c91f13
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+* 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 <common/memory.h>
+
+#include <boost/noncopyable.hpp>
+#include <boost/property_tree/ptree_fwd.hpp>
+
+#include <functional>
+#include <string>
+
+namespace caspar { namespace core {
+
+typedef std::function<void (boost::property_tree::wptree& info)> system_info_provider;
+typedef std::function<std::wstring ()> version_provider;
+
+class system_info_provider_repository : boost::noncopyable
+{
+public:
+       system_info_provider_repository();
+       void register_system_info_provider(system_info_provider provider);
+       void register_version_provider(const std::wstring& version_name, version_provider provider);
+       void fill_information(boost::property_tree::wptree& info) const;
+       std::wstring get_version(const std::wstring& version_name) const;
+private:
+       struct impl;
+       spl::shared_ptr<impl> impl_;
+};
+
+}}
index b01e51f46f015f5e307d74bf4df999856d34bb1c..785ac469744a7ee73f384e0e0450ab10a5ab178d 100644 (file)
 #include <common/utf.h>
 
 #include <core/consumer/frame_consumer.h>
+#include <core/system_info_provider.h>
 
 #include <boost/lexical_cast.hpp>
+#include <boost/property_tree/ptree.hpp>
 
 namespace caspar { namespace bluefish {
 
-void init()
-{
-       try
-       {
-               blue_initialize();
-               core::register_consumer_factory([](const std::vector<std::wstring>& params)
-               {
-                       return create_consumer(params);
-               });
-       }
-       catch(...){}
-}
-
 std::wstring version()
 {
        try
@@ -87,4 +76,25 @@ std::vector<std::wstring> device_list()
        return devices;
 }
 
+void init(const spl::shared_ptr<core::system_info_provider_repository>& repo)
+{
+       try
+       {
+               blue_initialize();
+       }
+       catch(...){}
+
+       core::register_consumer_factory([](const std::vector<std::wstring>& params)
+       {
+               return create_consumer(params);
+       });
+       repo->register_system_info_provider([](boost::property_tree::wptree& info)
+       {
+               info.add(L"system.bluefish.version", version());
+
+               for (auto device : device_list())
+                       info.add(L"system.bluefish.device", device);
+       });
+}
+
 }}
\ No newline at end of file
index 716193059a5cd21b4b66b403014f2033e7cb0073..390f5dec44aeb29436da260182ea4f6a600cb512 100644 (file)
 #include <string>
 #include <vector>
 
-namespace caspar { namespace bluefish {
+#include <common/memory.h>
 
-void init();
+namespace caspar {
+namespace core {
 
-std::wstring version();
-std::vector<std::wstring> device_list();
+class system_info_provider_repository;
+
+}
+
+namespace bluefish {
+
+void init(const spl::shared_ptr<core::system_info_provider_repository>& repo);
 
 }}
\ No newline at end of file
index 4252e99d28fb08706390270ab9708000158b0aa0..7d0a4580658db1a61ec476759e94b0908187832c 100644 (file)
@@ -29,6 +29,9 @@
 
 #include <core/consumer/frame_consumer.h>
 #include <core/producer/frame_producer.h>
+#include <core/system_info_provider.h>
+
+#include <boost/property_tree/ptree.hpp>
 
 #include "interop/DeckLinkAPI_h.h"
 
 
 namespace caspar { namespace decklink {
 
-void init()
-{
-       struct co_init
-       {
-               co_init(){::CoInitialize(nullptr);}
-               ~co_init(){::CoUninitialize();}
-       } init;
-       
-       CComPtr<IDeckLinkIterator> pDecklinkIterator;
-       if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))         
-               return;
-               
-       core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_consumer(params);});
-       core::register_producer_factory(create_producer);
-}
-
-std::wstring version() 
+std::wstring version()
 {
        std::wstring version = L"Not found";
-       
+
        struct co_init
        {
-               co_init(){::CoInitialize(nullptr);}
-               ~co_init(){::CoUninitialize();}
+               co_init(){ ::CoInitialize(nullptr); }
+               ~co_init(){ ::CoUninitialize(); }
        } init;
 
        try
        {
                CComPtr<IDeckLinkIterator> pDecklinkIterator;
-               if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))              
+               if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
                        version = decklink::version(pDecklinkIterator);
        }
-       catch(...){}
+       catch (...){}
 
        return version;
 }
@@ -84,31 +71,54 @@ std::wstring version()
 std::vector<std::wstring> device_list()
 {
        std::vector<std::wstring> devices;
-       
+
        struct co_init
        {
-               co_init(){::CoInitialize(nullptr);}
-               ~co_init(){::CoUninitialize();}
+               co_init(){ ::CoInitialize(nullptr); }
+               ~co_init(){ ::CoUninitialize(); }
        } init;
 
        try
        {
                CComPtr<IDeckLinkIterator> pDecklinkIterator;
-               if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
-               {               
+               if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
+               {
                        IDeckLink* decklink;
-                       for(int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n) 
+                       for (int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n)
                        {
                                BSTR model_name = L"Unknown";
                                decklink->GetModelName(&model_name);
                                decklink->Release();
-                               devices.push_back(std::wstring(model_name) + L" [" + boost::lexical_cast<std::wstring>(n) + L"]");      
+                               devices.push_back(std::wstring(model_name) + L" [" + boost::lexical_cast<std::wstring>(n)+L"]");
                        }
                }
        }
-       catch(...){}
+       catch (...){}
 
        return devices;
 }
 
+void init(const spl::shared_ptr<core::system_info_provider_repository>& repo)
+{
+       struct co_init
+       {
+               co_init(){::CoInitialize(nullptr);}
+               ~co_init(){::CoUninitialize();}
+       } init;
+       
+       CComPtr<IDeckLinkIterator> pDecklinkIterator;
+       if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))         
+               return;
+               
+       core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_consumer(params);});
+       core::register_producer_factory(create_producer);
+       repo->register_system_info_provider([](boost::property_tree::wptree& info)
+       {
+               info.add(L"system.decklink.version", version());
+
+               for (auto device : device_list())
+                       info.add(L"system.decklink.device", device);
+       });
+}
+
 }}
\ No newline at end of file
index db268b8a87a4875bb00d3b1ef80a1db6c94b2319..060a9ca6f68feceedd4ae890f749876f71072ad6 100644 (file)
 #include <string>
 #include <vector>
 
-namespace caspar { namespace decklink {
+#include <common/memory.h>
 
-void init();
+namespace caspar {
+namespace core {
 
-std::wstring version();
-std::vector<std::wstring> device_list();
+class system_info_provider_repository;
+
+}
+
+namespace decklink {
+
+void init(const spl::shared_ptr<core::system_info_provider_repository>& repo);
 
 }}
\ No newline at end of file
index 9a5d650f44245d0a6c0aa85a46781e5fd77bf5c6..b0b59ae8002ec3da1feb45cb592ea4fc5aa93a7e 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "StdAfx.h"
 
+#include "ffmpeg.h"
+
 #include "consumer/ffmpeg_consumer.h"
 #include "producer/ffmpeg_producer.h"
 #include "producer/util/util.h"
@@ -31,6 +33,9 @@
 #include <core/producer/frame_producer.h>
 #include <core/producer/media_info/media_info.h>
 #include <core/producer/media_info/media_info_repository.h>
+#include <core/system_info_provider.h>
+
+#include <boost/property_tree/ptree.hpp>
 
 #include <tbb/recursive_mutex.h>
 
@@ -198,7 +203,41 @@ void log_callback(void* ptr, int level, const char* fmt, va_list vl)
 //}
 //#pragma warning (pop)
 
-void init(const spl::shared_ptr<core::media_info_repository>& media_info_repo)
+std::wstring make_version(unsigned int ver)
+{
+       std::wstringstream str;
+       str << ((ver >> 16) & 0xFF) << L"." << ((ver >> 8) & 0xFF) << L"." << ((ver >> 0) & 0xFF);
+       return str.str();
+}
+
+std::wstring avcodec_version()
+{
+       return make_version(::avcodec_version());
+}
+
+std::wstring avformat_version()
+{
+       return make_version(::avformat_version());
+}
+
+std::wstring avutil_version()
+{
+       return make_version(::avutil_version());
+}
+
+std::wstring avfilter_version()
+{
+       return make_version(::avfilter_version());
+}
+
+std::wstring swscale_version()
+{
+       return make_version(::swscale_version());
+}
+
+void init(
+               const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& system_info_repo)
 {
        av_lockmgr_register(ffmpeg_lock_callback);
        av_log_set_callback(log_callback);
@@ -230,7 +269,14 @@ void init(const spl::shared_ptr<core::media_info_repository>& media_info_repo)
 
                                return try_get_duration(file, info.duration, info.time_base);
                        });
-
+       system_info_repo->register_system_info_provider([](boost::property_tree::wptree& info)
+       {
+               info.add(L"system.ffmpeg.avcodec", avcodec_version());
+               info.add(L"system.ffmpeg.avformat", avformat_version());
+               info.add(L"system.ffmpeg.avfilter", avfilter_version());
+               info.add(L"system.ffmpeg.avutil", avutil_version());
+               info.add(L"system.ffmpeg.swscale", swscale_version());
+       });
 }
 
 void uninit()
@@ -240,36 +286,4 @@ void uninit()
        av_lockmgr_register(nullptr);
 }
 
-std::wstring make_version(unsigned int ver)
-{
-       std::wstringstream str;
-       str << ((ver >> 16) & 0xFF) << L"." << ((ver >> 8) & 0xFF) << L"." << ((ver >> 0) & 0xFF);
-       return str.str();
-}
-
-std::wstring avcodec_version()
-{
-       return make_version(::avcodec_version());
-}
-
-std::wstring avformat_version()
-{
-       return make_version(::avformat_version());
-}
-
-std::wstring avutil_version()
-{
-       return make_version(::avutil_version());
-}
-
-std::wstring avfilter_version()
-{
-       return make_version(::avfilter_version());
-}
-
-std::wstring swscale_version()
-{
-       return make_version(::swscale_version());
-}
-
 }}
\ No newline at end of file
index 1119f0033c1d7ee7ad1582791abd06d2ba40573d..e96e8b067eac3061d083087892d21079ae3e50ae 100644 (file)
@@ -29,18 +29,15 @@ namespace caspar {
 namespace core {
 
 struct media_info_repository;
+class system_info_provider_repository;
 
 }
 
 namespace ffmpeg {
 
-void init(const spl::shared_ptr<core::media_info_repository>& media_info_repo);
+void init(
+               const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& system_info_repo);
 void uninit();
 
-std::wstring avcodec_version();
-std::wstring avformat_version();
-std::wstring avutil_version();
-std::wstring avfilter_version();
-std::wstring swscale_version();
-
 }}
\ No newline at end of file
index 753ec25a1c46535efd145f4b3f2b6e0ac9093195..5e35599cfcffffca1cb96dff828d79825b5494eb 100644 (file)
 
 #include <core/producer/media_info/media_info.h>
 #include <core/producer/media_info/media_info_repository.h>
+#include <core/system_info_provider.h>
+
+#include <boost/property_tree/ptree.hpp>
 
 #include <string>
 
 namespace caspar { namespace flash {
 
-void init(const spl::shared_ptr<core::media_info_repository>& media_info_repo)
+std::wstring version();
+std::wstring cg_version();
+
+void init(
+               const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& info_provider_repo)
 {
        core::register_producer_factory(create_ct_producer);
        core::register_producer_factory(create_swf_producer);
@@ -49,6 +57,12 @@ void init(const spl::shared_ptr<core::media_info_repository>& media_info_repo)
 
                return true;
        });
+       info_provider_repo->register_system_info_provider([](boost::property_tree::wptree& info)
+       {
+               info.add(L"system.flash", version());
+       });
+       info_provider_repo->register_version_provider(L"FLASH", &version);
+       info_provider_repo->register_version_provider(L"TEMPLATEHOST", &cg_version);
 }
 
 std::wstring cg_version()
index 945ebb359fde5a68139bcb666863fa31fa86da16..1dcec35502ac5441d9381b3395814beb729c114d 100644 (file)
@@ -21,8 +21,6 @@
 
 #pragma once
 
-#include <string>
-
 #include <common/memory.h>
 
 namespace caspar {
@@ -30,14 +28,14 @@ namespace caspar {
 namespace core {
 
 struct media_info_repository;
+class system_info_provider_repository;
 
 }
 
 namespace flash {
 
-void init(const spl::shared_ptr<core::media_info_repository>& media_info_repo);
-
-std::wstring cg_version();
-std::wstring version();
+void init(
+               const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& info_provider_repo);
 
 }}
\ No newline at end of file
index d912afe5d05224fc360a545315a7d2ce65c19dd2..ffad16b3a4d3bde56a92372222e53d9633b7f301 100644 (file)
 #include <core/consumer/frame_consumer.h>
 #include <core/producer/media_info/media_info.h>
 #include <core/producer/media_info/media_info_repository.h>
+#include <core/system_info_provider.h>
 
 #include <common/utf.h>
 
+#include <boost/property_tree/ptree.hpp>
+
 #include <FreeImage.h>
 
 namespace caspar { namespace image {
 
-void init(const spl::shared_ptr<core::media_info_repository>& repo)
+std::wstring version()
+{
+       return u16(FreeImage_GetVersion());
+}
+
+void init(
+               const spl::shared_ptr<core::media_info_repository>& repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& system_info_repo)
 {
        FreeImage_Initialise();
        core::register_producer_factory(create_scroll_producer);
@@ -60,6 +70,10 @@ void init(const spl::shared_ptr<core::media_info_repository>& repo)
 
                return false;
        });
+       system_info_repo->register_system_info_provider([](boost::property_tree::wptree& info)
+       {
+               info.add(L"system.freeimage", version());
+       });
 }
 
 void uninit()
@@ -67,10 +81,4 @@ void uninit()
        FreeImage_DeInitialise();
 }
 
-
-std::wstring version()
-{
-       return u16(FreeImage_GetVersion());
-}
-
-}}
\ No newline at end of file
+}}
index 8a7655ef4f68d321bd6c6f1f23c64d1a7a4063ef..888865052018a42576ee40a73d4a64e137888e70 100644 (file)
@@ -30,14 +30,15 @@ namespace caspar {
 namespace core {
 
 struct media_info_repository;
+class system_info_provider_repository;
 
 }
 
 namespace image {
 
-void init(const spl::shared_ptr<core::media_info_repository>& repo);
+void init(
+               const spl::shared_ptr<core::media_info_repository>& repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& system_info_repo);
 void uninit();
 
-std::wstring version();
-
-}}
\ No newline at end of file
+}}
index 48f323ba3fa93a69071e459241debcbcdcae9f14..44224daeb4cc6971f73231abff510b47df85af97 100644 (file)
 #include <core/producer/media_info/media_info_repository.h>
 #include <core/diagnostics/call_context.h>
 #include <core/diagnostics/osd_graph.h>
+#include <core/system_info_provider.h>
 
 #include <modules/reroute/producer/reroute_producer.h>
-#include <modules/bluefish/bluefish.h>
-#include <modules/decklink/decklink.h>
-#include <modules/ffmpeg/ffmpeg.h>
 #include <modules/flash/flash.h>
 #include <modules/flash/util/swf.h>
 #include <modules/flash/producer/flash_producer.h>
 #include <modules/flash/producer/cg_proxy.h>
-#include <modules/ffmpeg/producer/util/util.h>
-#include <modules/screen/screen.h>
 
 #include <algorithm>
 #include <locale>
@@ -1523,19 +1519,8 @@ bool InfoCommand::DoExecute()
                        info.add(L"system.name",                                        caspar::system_product_name());
                        info.add(L"system.os.description",                      caspar::os_description());
                        info.add(L"system.cpu",                                         caspar::cpu_info());
-       
-                       for (auto& device : caspar::decklink::device_list())
-                               info.add(L"system.decklink.device", device);
 
-                       for (auto& device : caspar::bluefish::device_list())
-                               info.add(L"system.bluefish.device", device);
-                               
-                       info.add(L"system.flash",                                       caspar::flash::version());
-                       info.add(L"system.ffmpeg.avcodec",                      caspar::ffmpeg::avcodec_version());
-                       info.add(L"system.ffmpeg.avformat",                     caspar::ffmpeg::avformat_version());
-                       info.add(L"system.ffmpeg.avfilter",                     caspar::ffmpeg::avfilter_version());
-                       info.add(L"system.ffmpeg.avutil",                       caspar::ffmpeg::avutil_version());
-                       info.add(L"system.ffmpeg.swscale",                      caspar::ffmpeg::swscale_version());
+                       repo_->fill_information(info);
                                                
                        boost::property_tree::write_xml(replyString, info, w);
                }
@@ -1665,14 +1650,14 @@ bool VersionCommand::DoExecute()
 {
        std::wstring replyString = L"201 VERSION OK\r\n" + env::version() + L"\r\n";
 
-       if(parameters().size() > 0)
+       if (parameters().size() > 0 && !boost::iequals(parameters()[0], L"SERVER"))
        {
-               if(boost::iequals(parameters()[0], L"FLASH"))
-                       replyString = L"201 VERSION OK\r\n" + flash::version() + L"\r\n";
-               else if(boost::iequals(parameters()[0], L"TEMPLATEHOST"))
-                       replyString = L"201 VERSION OK\r\n" + flash::cg_version() + L"\r\n";
-               else if(!boost::iequals(parameters()[0], L"SERVER"))
+               auto version = repo_->get_version(parameters().at(0));
+
+               if (version.empty())
                        replyString = L"403 VERSION ERROR\r\n";
+               else
+                       replyString = L"201 VERSION OK\r\n" + version + L"\r\n";
        }
 
        SetReplyString(replyString);
index a4763ae1e117183f211c138407ea99af8822f5ef..6a9cd468bc37bdd324eff91be83139dcd4bdc3e6 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <core/thumbnail_generator.h>
 #include <core/producer/media_info/media_info_repository.h>
+#include <core/system_info_provider.h>
 
 #include <future>
 
@@ -260,17 +261,28 @@ private:
 class InfoCommand : public AMCPCommandBase<0>, AMCPChannelsAwareCommand
 {
 public:
-       InfoCommand(IO::ClientInfoPtr client, const std::vector<channel_context>& channels) : AMCPChannelsAwareCommand(channels), AMCPCommandBase(client) {}
+       InfoCommand(IO::ClientInfoPtr client, const std::vector<channel_context>& channels, const spl::shared_ptr<core::system_info_provider_repository>& repo)
+               : AMCPChannelsAwareCommand(channels)
+               , AMCPCommandBase(client)
+               , repo_(repo)
+       {}
        std::wstring print() const { return L"InfoCommand";}
        bool DoExecute();
+private:
+       spl::shared_ptr<core::system_info_provider_repository> repo_;
 };
 
 class VersionCommand : public AMCPCommandBase<0>
 {
 public:
-       explicit VersionCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
+       explicit VersionCommand(IO::ClientInfoPtr client, const spl::shared_ptr<core::system_info_provider_repository>& repo)
+               : AMCPCommandBase(client)
+               , repo_(repo)
+       {}
        std::wstring print() const { return L"VersionCommand";}
        bool DoExecute();
+private:
+       spl::shared_ptr<core::system_info_provider_repository> repo_;
 };
 
 class ByeCommand : public AMCPCommandBase<0>
index d6dce4ad24f3ec8e6cb442ac3780eb4baca746b5..a918e7dcea065810881dc13f0149c065f5aed119 100644 (file)
@@ -51,20 +51,23 @@ using IO::ClientInfoPtr;
 struct AMCPProtocolStrategy::impl
 {
 private:
-       std::vector<channel_context>                                    channels_;
-       std::vector<AMCPCommandQueue::ptr_type>                 commandQueues_;
-       std::shared_ptr<core::thumbnail_generator>              thumb_gen_;
-       spl::shared_ptr<core::media_info_repository>    media_info_repo_;
-       std::promise<bool>&                                                             shutdown_server_now_;
+       std::vector<channel_context>                                                    channels_;
+       std::vector<AMCPCommandQueue::ptr_type>                                 commandQueues_;
+       std::shared_ptr<core::thumbnail_generator>                              thumb_gen_;
+       spl::shared_ptr<core::media_info_repository>                    media_info_repo_;
+       spl::shared_ptr<core::system_info_provider_repository>  system_info_provider_repo_;
+       std::promise<bool>&                                                                             shutdown_server_now_;
 
 public:
        impl(
                        const std::vector<spl::shared_ptr<core::video_channel>>& channels,
                        const std::shared_ptr<core::thumbnail_generator>& thumb_gen,
                        const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+                       const spl::shared_ptr<core::system_info_provider_repository>& system_info_provider_repo,
                        std::promise<bool>& shutdown_server_now)
                : thumb_gen_(thumb_gen)
                , media_info_repo_(media_info_repo)
+               , system_info_provider_repo_(system_info_provider_repo)
                , shutdown_server_now_(shutdown_server_now)
        {
                commandQueues_.push_back(std::make_shared<AMCPCommandQueue>());
@@ -355,20 +358,20 @@ private:
        AMCPCommand::ptr_type create_command(const std::wstring& str, ClientInfoPtr client)
        {
                std::wstring s = boost::to_upper_copy(str);
-               if(s == L"DIAG")                                return std::make_shared<DiagnosticsCommand>(client);
-               else if(s == L"CHANNEL_GRID")   return std::make_shared<ChannelGridCommand>(client, channels_);
-               else if(s == L"DATA")                   return std::make_shared<DataCommand>(client);
-               else if(s == L"CINF")                   return std::make_shared<CinfCommand>(client, media_info_repo_);
-               else if(s == L"INFO")                   return std::make_shared<InfoCommand>(client, channels_);
-               else if(s == L"CLS")                    return std::make_shared<ClsCommand>(client, media_info_repo_);
-               else if(s == L"TLS")                    return std::make_shared<TlsCommand>(client);
-               else if(s == L"VERSION")                return std::make_shared<VersionCommand>(client);
-               else if(s == L"BYE")                    return std::make_shared<ByeCommand>(client);
-               else if(s == L"LOCK")                   return std::make_shared<LockCommand>(client, channels_);
-               else if(s == L"LOG")                    return std::make_shared<LogCommand>(client);
-               else if(s == L"THUMBNAIL")              return std::make_shared<ThumbnailCommand>(client, thumb_gen_);
-               else if(s == L"KILL")                   return std::make_shared<KillCommand>(client, shutdown_server_now_);
-               else if(s == L"RESTART")                return std::make_shared<RestartCommand>(client, shutdown_server_now_);
+               if (     s == L"DIAG")                  return std::make_shared<DiagnosticsCommand>(client);
+               else if (s == L"CHANNEL_GRID")  return std::make_shared<ChannelGridCommand>(client, channels_);
+               else if (s == L"DATA")                  return std::make_shared<DataCommand>(client);
+               else if (s == L"CINF")                  return std::make_shared<CinfCommand>(client, media_info_repo_);
+               else if (s == L"INFO")                  return std::make_shared<InfoCommand>(client, channels_, system_info_provider_repo_);
+               else if (s == L"CLS")                   return std::make_shared<ClsCommand>(client, media_info_repo_);
+               else if (s == L"TLS")                   return std::make_shared<TlsCommand>(client);
+               else if (s == L"VERSION")               return std::make_shared<VersionCommand>(client, system_info_provider_repo_);
+               else if (s == L"BYE")                   return std::make_shared<ByeCommand>(client);
+               else if (s == L"LOCK")                  return std::make_shared<LockCommand>(client, channels_);
+               else if (s == L"LOG")                   return std::make_shared<LogCommand>(client);
+               else if (s == L"THUMBNAIL")             return std::make_shared<ThumbnailCommand>(client, thumb_gen_);
+               else if (s == L"KILL")                  return std::make_shared<KillCommand>(client, shutdown_server_now_);
+               else if (s == L"RESTART")               return std::make_shared<RestartCommand>(client, shutdown_server_now_);
 
                return nullptr;
        }
@@ -401,8 +404,9 @@ AMCPProtocolStrategy::AMCPProtocolStrategy(
                const std::vector<spl::shared_ptr<core::video_channel>>& channels,
                const std::shared_ptr<core::thumbnail_generator>& thumb_gen,
                const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+               const spl::shared_ptr<core::system_info_provider_repository>& system_info_provider_repo,
                std::promise<bool>& shutdown_server_now)
-       : impl_(spl::make_unique<impl>(channels, thumb_gen, media_info_repo, shutdown_server_now))
+       : impl_(spl::make_unique<impl>(channels, thumb_gen, media_info_repo, system_info_provider_repo, shutdown_server_now))
 {
 }
 AMCPProtocolStrategy::~AMCPProtocolStrategy() {}
index 7afd59254e92e26f0fb5fcce93aca7a594d201d1..b65915dd1ef170feffdbde326db75f620e25c2a3 100644 (file)
@@ -26,6 +26,7 @@
 #include <core/video_channel.h>
 #include <core/thumbnail_generator.h>
 #include <core/producer/media_info/media_info_repository.h>
+#include <core/system_info_provider.h>
 
 #include <common/memory.h>
 
@@ -40,10 +41,11 @@ class AMCPProtocolStrategy : public IO::IProtocolStrategy, boost::noncopyable
 {
 public:
        AMCPProtocolStrategy(
-               const std::vector<spl::shared_ptr<core::video_channel>>& channels, 
-               const std::shared_ptr<core::thumbnail_generator>& thumb_gen,
-               const spl::shared_ptr<core::media_info_repository>& media_info_repo,
-               std::promise<bool>& shutdown_server_now);
+                       const std::vector<spl::shared_ptr<core::video_channel>>& channels,
+                       const std::shared_ptr<core::thumbnail_generator>& thumb_gen,
+                       const spl::shared_ptr<core::media_info_repository>& media_info_repo,
+                       const spl::shared_ptr<core::system_info_provider_repository>& system_info_provider_repo,
+                       std::promise<bool>& shutdown_server_now);
 
        virtual ~AMCPProtocolStrategy();
 
index 233740eddcefda47f3a3029f610f356aa2799f37..d08d97b9164496fd2ecf67995bf224365be930ba 100644 (file)
 #include <protocol/util/strategy_adapters.h>
 #include <protocol/amcp/AMCPProtocolStrategy.h>
 
-#include <modules/bluefish/bluefish.h>
-#include <modules/decklink/decklink.h>
-#include <modules/flash/flash.h>
-#include <modules/ffmpeg/ffmpeg.h>
-#include <modules/image/image.h>
-
 #include <common/env.h>
 #include <common/except.h>
 #include <common/log.h>
@@ -61,6 +55,8 @@
 #include <common/os/system_info.h>
 #include <common/os/general_protection_fault.h>
 
+#include <core/system_info_provider.h>
+
 #include <boost/property_tree/detail/file_parser_error.hpp>
 #include <boost/property_tree/xml_parser.hpp>
 #include <boost/locale.hpp>
@@ -146,22 +142,44 @@ void print_info()
        CASPAR_LOG(info) << L"on " << os_description();
        CASPAR_LOG(info) << cpu_info();
        CASPAR_LOG(info) << system_product_name();
+}
+
+void print_child(const std::wstring& indent, const std::wstring& elem, const boost::property_tree::wptree& tree)
+{
+       auto data = tree.data();
+
+       if (data.empty())
+               CASPAR_LOG(info) << indent << elem;
+       else
+               CASPAR_LOG(info) << indent << elem << L" " << tree.data();
+
+       for (auto& child : tree)
+               print_child(indent + L"    ", child.first, child.second);
+}
+
+void print_system_info(const spl::shared_ptr<core::system_info_provider_repository>& repo)
+{
+       boost::property_tree::wptree info;
+       repo->fill_information(info);
        
-       CASPAR_LOG(info) << L"Decklink " << decklink::version();
+       /*CASPAR_LOG(info) << L"Decklink " << decklink::version();
        for (auto device : decklink::device_list())
                CASPAR_LOG(info) << L" - " << device;
                
        CASPAR_LOG(info) << L"Bluefish " << bluefish::version();
        for (auto device : bluefish::device_list())
-               CASPAR_LOG(info) << L" - " << device;
-       
-       CASPAR_LOG(info) << L"Flash "                   << flash::version();
-       CASPAR_LOG(info) << L"FreeImage "               << image::version();
-       CASPAR_LOG(info) << L"FFMPEG-avcodec "  << ffmpeg::avcodec_version();
+               CASPAR_LOG(info) << L" - " << device;*/
+
+       for (auto& elem : info.get_child(L"system"))
+               print_child(L"", elem.first, elem.second);
+
+       //CASPAR_LOG(info) << L"Flash "                 << flash::version();
+       //CASPAR_LOG(info) << L"FreeImage "             << image::version();
+       /*CASPAR_LOG(info) << L"FFMPEG-avcodec "  << ffmpeg::avcodec_version();
        CASPAR_LOG(info) << L"FFMPEG-avformat " << ffmpeg::avformat_version();
        CASPAR_LOG(info) << L"FFMPEG-avfilter " << ffmpeg::avfilter_version();
        CASPAR_LOG(info) << L"FFMPEG-avutil "   << ffmpeg::avutil_version();
-       CASPAR_LOG(info) << L"FFMPEG-swscale "  << ffmpeg::swscale_version();
+       CASPAR_LOG(info) << L"FFMPEG-swscale "  << ffmpeg::swscale_version();*/
 }
 
 LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info)
@@ -196,6 +214,7 @@ void do_run(server& caspar_server, std::promise<bool>& shutdown_server_now)
                                                        caspar_server.channels(),
                                                        caspar_server.get_thumbnail_generator(),
                                                        caspar_server.get_media_info_repo(),
+                                                       caspar_server.get_system_info_provider_repo(),
                                                        shutdown_server_now)))->create(console_client);
 
        std::wstring wcmd;
@@ -294,9 +313,21 @@ bool run()
        std::promise<bool> shutdown_server_now;
        std::future<bool> shutdown_server = shutdown_server_now.get_future();
 
+       print_info();
+
        // Create server object which initializes channels, protocols and controllers.
        server caspar_server(shutdown_server_now);
        
+       // Print environment information.
+       print_system_info(caspar_server.get_system_info_provider_repo());
+
+       std::wstringstream str;
+       boost::property_tree::xml_writer_settings<std::wstring> w(' ', 3);
+       boost::property_tree::write_xml(str, env::properties(), w);
+       CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";
+       
+       caspar_server.start();
+
        //auto console_obs = reactive::make_observer([](const monitor::event& e)
        //{
        //      std::stringstream str;
@@ -388,14 +419,6 @@ int main(int argc, wchar_t* argv[])
                // Setup console window.
                setup_console_window();
 
-               // Print environment information.
-               print_info();
-               
-               std::wstringstream str;
-               boost::property_tree::xml_writer_settings<std::wstring> w(' ', 3);
-               boost::property_tree::write_xml(str, env::properties(), w);
-               CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";
-               
                return_code = run() ? 5 : 0;
                
                Sleep(500);
index ba8ef8aca18d7d7e130dd0ec82a38201e099451e..ce3657a67cdec0326343249b2689177a88c1a71a 100644 (file)
@@ -45,6 +45,7 @@
 #include <core/diagnostics/subject_diagnostics.h>
 #include <core/diagnostics/call_context.h>
 #include <core/diagnostics/osd_graph.h>
+#include <core/system_info_provider.h>
 
 #include <modules/bluefish/bluefish.h>
 #include <modules/decklink/decklink.h>
@@ -98,6 +99,7 @@ struct server::impl : boost::noncopyable
        std::vector<spl::shared_ptr<video_channel>>                     channels_;
        spl::shared_ptr<media_info_repository>                          media_info_repo_;
        boost::thread                                                                           initial_media_info_thread_;
+       spl::shared_ptr<system_info_provider_repository>        system_info_provider_repo_;
        tbb::atomic<bool>                                                                       running_;
        std::shared_ptr<thumbnail_generator>                            thumbnail_generator_;
        std::promise<bool>&                                                                     shutdown_server_now_;
@@ -108,17 +110,17 @@ struct server::impl : boost::noncopyable
                , media_info_repo_(create_in_memory_media_info_repository())
                , shutdown_server_now_(shutdown_server_now)
        {
-               running_ = true;
+               running_ = false;
                core::diagnostics::osd::register_sink();
                diag_subject_->attach_parent(monitor_subject_);
 
-               ffmpeg::init(media_info_repo_);
+               ffmpeg::init(media_info_repo_, system_info_provider_repo_);
                CASPAR_LOG(info) << L"Initialized ffmpeg module.";
                                                          
-               bluefish::init();         
+               bluefish::init(system_info_provider_repo_);
                CASPAR_LOG(info) << L"Initialized bluefish module.";
                                                          
-               decklink::init();         
+               decklink::init(system_info_provider_repo_);       
                CASPAR_LOG(info) << L"Initialized decklink module.";
                                                                                                                  
                oal::init();              
@@ -127,10 +129,10 @@ struct server::impl : boost::noncopyable
                screen::init();           
                CASPAR_LOG(info) << L"Initialized ogl module.";
 
-               image::init(media_info_repo_);
+               image::init(media_info_repo_, system_info_provider_repo_);
                CASPAR_LOG(info) << L"Initialized image module.";
 
-               flash::init(media_info_repo_);
+               flash::init(media_info_repo_, system_info_provider_repo_);
                CASPAR_LOG(info) << L"Initialized flash module.";
 
                psd::init();              
@@ -140,6 +142,11 @@ struct server::impl : boost::noncopyable
 
                register_producer_factory(&core::scene::create_dummy_scene_producer);
                register_producer_factory(&core::scene::create_xml_scene_producer);
+       }
+
+       void start()
+       {
+               running_ = true;
 
                setup_channels(env::properties());
                CASPAR_LOG(info) << L"Initialized channels.";
@@ -159,8 +166,12 @@ struct server::impl : boost::noncopyable
 
        ~impl()
        {
-               running_ = false;
-               initial_media_info_thread_.join();
+               if (running_)
+               {
+                       running_ = false;
+                       initial_media_info_thread_.join();
+               }
+
                thumbnail_generator_.reset();
                primary_amcp_server_.reset();
                async_servers_.clear();
@@ -322,7 +333,7 @@ struct server::impl : boost::noncopyable
                using namespace IO;
 
                if(boost::iequals(name, L"AMCP"))
-                       return wrap_legacy_protocol("\r\n", spl::make_shared<amcp::AMCPProtocolStrategy>(channels_, thumbnail_generator_, media_info_repo_, shutdown_server_now_));
+                       return wrap_legacy_protocol("\r\n", spl::make_shared<amcp::AMCPProtocolStrategy>(channels_, thumbnail_generator_, media_info_repo_, system_info_provider_repo_, shutdown_server_now_));
                else if(boost::iequals(name, L"CII"))
                        return wrap_legacy_protocol("\r\n", spl::make_shared<cii::CIIProtocolStrategy>(channels_));
                else if(boost::iequals(name, L"CLOCK"))
@@ -357,13 +368,14 @@ struct server::impl : boost::noncopyable
 };
 
 server::server(std::promise<bool>& shutdown_server_now) : impl_(new impl(shutdown_server_now)){}
-
+void server::start() { impl_->start(); }
 const std::vector<spl::shared_ptr<video_channel>> server::channels() const
 {
        return impl_->channels_;
 }
 std::shared_ptr<core::thumbnail_generator> server::get_thumbnail_generator() const {return impl_->thumbnail_generator_; }
 spl::shared_ptr<media_info_repository> server::get_media_info_repo() const { return impl_->media_info_repo_; }
+spl::shared_ptr<core::system_info_provider_repository> server::get_system_info_provider_repo() const { return impl_->system_info_provider_repo_; }
 core::monitor::subject& server::monitor_output() { return *impl_->monitor_subject_; }
 
 }
index 6f21f7d5a7e8af55dcee3b17a69f874760c22d3e..c7a0801f8418550f535401dd31816c1d7f118938 100644 (file)
@@ -36,15 +36,18 @@ namespace core {
        class video_channel;
        class thumbnail_generator;
        struct media_info_repository;
+       class system_info_provider_repository;
 }
 
 class server final : public boost::noncopyable
 {
 public:
        explicit server(std::promise<bool>& shutdown_server_now);
+       void start();
        const std::vector<spl::shared_ptr<core::video_channel>> channels() const;
        std::shared_ptr<core::thumbnail_generator> get_thumbnail_generator() const;
        spl::shared_ptr<core::media_info_repository> get_media_info_repo() const;
+       spl::shared_ptr<core::system_info_provider_repository> get_system_info_provider_repo() const;
 
        core::monitor::subject& monitor_output();
 private: