producer/layer.cpp
producer/stage.cpp
+ system_info_provider.cpp
StdAfx.cpp
thumbnail_generator.cpp
video_channel.cpp
producer/stage.h
producer/variable.h
- frame.h
+ system_info_provider.h
StdAfx.h
thumbnail_generator.h
video_channel.h
+++ /dev/null
-#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
--- /dev/null
+/*
+* 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);
+}
+
+}}
--- /dev/null
+/*
+* 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_;
+};
+
+}}
#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
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
#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
#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;
}
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
#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
#include "StdAfx.h"
+#include "ffmpeg.h"
+
#include "consumer/ffmpeg_consumer.h"
#include "producer/ffmpeg_producer.h"
#include "producer/util/util.h"
#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>
//}
//#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);
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()
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
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
#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);
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()
#pragma once
-#include <string>
-
#include <common/memory.h>
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
#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);
return false;
});
+ system_info_repo->register_system_info_provider([](boost::property_tree::wptree& info)
+ {
+ info.add(L"system.freeimage", version());
+ });
}
void uninit()
FreeImage_DeInitialise();
}
-
-std::wstring version()
-{
- return u16(FreeImage_GetVersion());
-}
-
-}}
\ No newline at end of file
+}}
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
+}}
#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>
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);
}
{
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);
#include <core/thumbnail_generator.h>
#include <core/producer/media_info/media_info_repository.h>
+#include <core/system_info_provider.h>
#include <future>
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>
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>());
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;
}
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() {}
#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>
{
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();
#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>
#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>
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)
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;
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;
// 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);
#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>
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_;
, 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();
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();
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.";
~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();
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"))
};
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_; }
}
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: